The CSS ID Selector

The "id" selector can only be used once per document when you are creating clean valid code.

It can be used multiple times but this is not recommended, classes should be used for repeat use.

The "id" selector is defined in either your inline or external CSS files using "#" and then a name. The name can not start with a number for example: "#1" would not work, this is browser specific but a rule of thumb is to never create styles for a single browser and therefore don't start the "id" with a number!

There are also as in the "class" selector 2 methods of declaring the "id" selector, whereby the HTML code is the same.

Example:

#content{ text-align:right; }

HTML:

<div id="content">Content Goes Here</div>

Using the following method you define a specific HTML tag to have the "id" attributes.

Example:

div#content{ text-align:right; }

HTML:

<div id="content">Content Goes Here</div>

The "id" can be used on all HTML tags that accept CSS styling, for example:

Example:

HTML:

<h1 id="logo">Headline Here</h1> <p id="copyright">My Text Here</p> <span id="bold">Specific Bold Tag</span>