ID selector

Matches the class property of the specified element.


#value {sRules}

Possible values


String that specifies the value of the id attribute.


String that specifies one or more cascading style sheet property/value pairs.


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 (#).


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.


The following style rule applies to the element with id="navigation" and its descendants:

    #navigation {line-height: 0px; font-size: x-small;}

Standards information

This selector is defined in Cascading Style Sheets (CSS), Level 1 (CSS1) Ee371275.xtlink_newWindow(en-us,Expression.40).png.

See also


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.