ID selectors

Sometimes you might want to style just one element. You could use a class applied only to that element. Another way is to use an ID for that element. In the stylesheet it works the same way as a class but you use a hash (#) instead of a dot (.):

    
#fred {
    color:green;
    font-size:12pt;
}        
        

Then in your document add this to the end but within the BODY:

<p id="fred">This paragraph can now be styled without affecting any other</p>
        

An ID should only be given to one HTML element on a page. You can use the same ID on another page.

You now know about three ways to choose which HTML is affected by styles:

submit to reddit Delicious Tweet