View Full Version : Real world convention for Class
codewarrior
08-23-2002, 03:52 AM
Just want to know what's the REAL WORLD convention for Class' in CSS?
.main {background-color:tan;}
or
.main {background-color:tan}
or
p.main {background-color:tan;}
Coz I've read about four (4) books and two (2) had the first one the other two had the latter one. So, I'm kinda confused here. :confused:
Thanks in advance. :)
adios
08-23-2002, 03:58 AM
Not sure what this has to do with classes; but the only difference I can see is the semicolon after the style declaration. Is that what you're referring to? Either way is fine, it's just a separator, optional when there's nothing to separate. Usage is generally recommended, to avoid the possibility of forgetting to add it when you append another declaration - this will cause trouble.
Very cute; OK, the 'p' selector restricts that particular class rule to <p> elements only. Without it, it's generally referred to as a 'free-range' class, like the chicken, applicable to all elements.
mouse
08-23-2002, 04:03 AM
.blah{}
Would apply .blah to any tag specifying class="blah"
h1.blah{}
Would apply .blah where the tag is <h1 class="blah">
For more info go here: http://www.w3.org/TR/REC-CSS2/selector.html#class-html
codewarrior
08-23-2002, 04:06 AM
Thanks! :D
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.