ID selector
Matches the class property of the specified element.
Syntax
#
value {
sRules }
Possible values
value |
String that specifies the value of the id attribute. |
sRules |
String that specifies one or more cascading style sheet property/value pairs. |
Remarks
The ID property allows authors to uniquely identify an element instance in the document tree. ID selectors match an element instance based on its identifier. The ID property value must immediately follow the number sign (#).
Note
Though some older browsers will allow multiple elements to share a single ID value, best-practices dictate that only one instance of a specific ID exist on a page. An element can have only one ID property.
In the event that a style declaration conflicts with another declaration, the rule with a higher level of specificity is used. (See Understanding selectors.) If a class selector and an ID selector are in conflict, the ID selector is chosen.
Example
The following style rule applies to the element with id="navigation"
and its descendants:
<style>
#navigation {line-height: 0px; font-size: x-small;}
</style>
Standards information
This selector is defined in Cascading Style Sheets (CSS), Level 1 (CSS1) .
See also
Concepts
Class selector
Equality attribute selector
Existence attribute selector
Hyphen attribute selector
Prefix attribute selector
Substring attribute selector
Suffix attribute selector
Type selector
Universal selector
Whitespace attribute selector
Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.