Export (0) Print
Expand All

ID Selector

Matches the class attribute of the specified element.

Syntax

HTML #value { sRules }
Scripting N/A

Possible Values

value String that specifies the value of the "id" attribute.
sRules String that specifies one or more Cascading Style Sheets (CSS) attribute/value pairs.

Remarks

The ID attribute allows authors to uniquely identify an element instance in the document tree. ID selectors match an element instance based on its identifier. The ID attribute value must immediately follow the "pound" (#) notation.

Note   Microsoft Internet Explorer allows multiple elements to share a single ID value. If more than one element exists, the style rule will apply to all elements with the given ID. Only one ID attribute may be present on any given element.

In the event that a style declaration conflicts with another declaration, the rule with a higher level of specificity is used. (See Understanding CSS Selectors.) If a Class Selector and 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 CSS, Level 1 (CSS1).

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
Show:
© 2014 Microsoft