9. CSS Id Selector

An id selector is the XHTML element with a matching id attribute that is to be given style or layout properties. An id selector is defined in CSS using the "#" sign followed by the value of the id attribute (no space between the "#" and the value of the id). An id attribute value is required to be unique; no two id's within an XHTML document may be the same.

Example 9.1 Id Selector Usage
<!DOCTYPE PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Element selector</title>
    <style type="text/css">
    #test {
        Property:Value;
    }
    </style>
</head>
<body>
    <div id="test">Styled by an id selector.</div>
</body>
</html>
    

In the above example an element with an id attribute with a value of test will be given style or layout properties.