Possible Duplicate:
HTML class attribute with spaces, it is a W3C valid class?
I'm using an existing HTML source code. Consider the following line:
<ul class="thumbs noscript">
What does an space mean between thumbs and noscript?
Possible Duplicate:
HTML class attribute with spaces, it is a W3C valid class?
I'm using an existing HTML source code. Consider the following line:
<ul class="thumbs noscript">
What does an space mean between thumbs and noscript?
The HTML element is using both of the classes which have been enlisted separated by a space.
A space is used to separate multiple classes in a class-declaration - so it basically means that both class thumbs
and noscript
apply to the UL-element.
To select an element that must have both those classes, through CSS, you can use a selector like this:
.thumbs.noscript {
/* Properties that apply to elements that have both classes. */
}
Notice that there is no space between the classes in the rule declaration in CSS. If you put a space between the classes, then noscript instead have to be a child of thumbs for the rule to apply.
A CSS-rule as the one above is useful when you want to apply CSS-properties to elements that have both classes, but not to elements that only have one, or non of the classes.
This means that this element has 2 classes. Both thumbs
and noscript
This means you can select this element using css like so:
.thumbs { color:#f00; }
.noscript { color:#000; }
OR
.thumbs.noscript { color:#fff; }
An element can have multiple classes, so in this case it has the classes "thumbs" and "noscript". So she space between the class names simply separates them.
Looking at the name chances are good that there is some CSS that e.g. always shows elements with the class "noscript". Using JavaScript this class is probably removed on page load to make the page work even nicer for anyone that has JavaScript enabled.
It's so you can use multiple classes - so you might be re-using a few in different areas of the site.
A real life example might be:
.thumbs {width:150px; height:150px; background-colour:#fff;}
.noscript {clear:both;}