Difference between revisions of "ID selector (CSS)"
From Wiki @ Karl Jones dot com
Karl Jones (Talk | contribs) |
Karl Jones (Talk | contribs) (→Description) |
||
Line 4: | Line 4: | ||
An ID rule must apply exactly one HTML element on a page (or no HTML element at all). | An ID rule must apply exactly one HTML element on a page (or no HTML element at all). | ||
+ | |||
+ | * See [[ID attribute (HTML)]] | ||
No two HTML elements on a given web page may have the same value for their ID attributes. | No two HTML elements on a given web page may have the same value for their ID attributes. |
Revision as of 10:23, 16 February 2016
In CSS, an ID selector (or ID style rule, or ID style) is a selector which selects zero or one HTML element based on the element's ID attribute.
Description
An ID rule must apply exactly one HTML element on a page (or no HTML element at all).
No two HTML elements on a given web page may have the same value for their ID attributes.
Example
ID style rule:
#example { color: red}
Element affected by rule:
<div id="example">...</div>
In the above example, div
is an arbitrary HTML element. Any other type of HTML element works the same.