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.

The "id" selector is defined in either your inline or extenal 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 therfore dont 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 CODE
<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 CODE
<div id="content">Content Goes Here</div>

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

Example:

HTML CODE
<h1 id="logo">CSS Tutorials</h1>
<p id="copyright">My Text Here</p>
<span id="bold">Specific Bold Tag</span>
etc....

Check Out Our Sponsors
Bookmarks
RSS Feed    Search
Remortgages