Twitter Updates

Sunday, 28 February 2010

HTML CSS id vs class

Working on some websites again, been away from HTML and CSS for a while and having to remind myself the difference between ids and class's.

id is for unique elements on a page. There should only ever be one of each id on a page.
< d i v id="navigation">< / d i v>

class is for many elements which you want to apply a custom style
< p r e  id="prettyprint">Code1< / p r e>
< p r e id="prettyprint">Code2< / p r e>

CSS for id:
div#navigation {background-color: white;}

CSS for class:
div.prettyprint {background-color: white;}


Original Source :
http://www.tizag.com/cssT/cssid.php

No comments: