...

View Full Version : What is the difference between .header or #header in CSS



joda
05-13-2009, 04:01 AM
I wish to figure out the difference between .header and if I write #header rules in a CSS file. I mean this content in a CSS file:

.header {
margin-left: auto;
margin-right: auto;
....
}

and this

#header {
margin-left: auto;
margin-right: auto;
....
}

What is the difference?
:confused:

JygzIsHere
05-13-2009, 04:24 AM
"." points to a class
"#" points to an id

example:

<div id="header">
Header ID DIV
</div>

<div class="header">
Header Class DIV
</div>


your .header style will affect the second example
and your #header style will affect the first.

twodayslate
05-13-2009, 04:28 AM
http://www.bernzilla.com/item.php?id=416

abduraooft
05-13-2009, 09:59 AM
http://htmldog.com/guides/cssintermediate/classid/

brazenskies
05-13-2009, 11:03 AM
it's all in those links I'm sure but if you can't be bothered reading them it's worth pointing out that an ID should be unique and can only be used once, classes can be used as many times as you like



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum