If it said "oneword", then I could write "#oneword", but what do I write when there is a space in the word?
views:
1331answers:
4
+14
A:
You can't have multiple words for the id, but you can for class.
<p class="one two">lalala</p>
.one {
color: black;
}
.two {
font-weight: bold;
}
Philip Morton
2008-10-30 11:39:14
+20
A:
If it contains spaces, it is not legal HTML. You shouldn't expect this to work. Here is the relevant section of the HTML 4.01 specification.
[EDIT] As others have noted, you can get around this by assigning one or more class names to the div and using a class name to do the selection.
tvanfosson
2008-10-30 11:40:50
+4
A:
You should not use whitespace in the ID element, as whitespace is generally accepted as a selector combinator.
Aron Rotteveel
2008-10-30 11:43:42
+1
A:
Change it to two-words. Like others said, you cannot use spaces for the id, but you can for the class.
#two-words { font-family: arial; }
.center { text-align: center; }
.bold { font-weight: bold; }
<div id="two-words" class="center bold">STUFF HERE</div>
rodey
2008-10-30 12:17:49