...

View Full Version : Why no validation?



kraftomatic
01-21-2004, 10:15 PM
So I get this error when trying to validate:

Line 56, column 128: ID "mgrey" already defined (explain...).

I'm using this ID within a DIV multiple times. What am I supposed to do? Create mgrey1, mgrey2, etc. that are all the same? The whole point of the CSS is to make changes in only one spot.

Am I missing something?

liorean
01-21-2004, 10:18 PM
Id is a way to identify a single element. No more than one element may have the same id. If you want to use CSS to style many elements, use class instead.

kraftomatic
01-21-2004, 10:24 PM
Doh! Thank you. :)

You can use SPAN tags with a class reference correct?

kraftomatic
01-21-2004, 10:51 PM
Hmm .. I have this:

#lgrey {
color: #ccc;
}

<li class="dgrey">2004 Schedule<br /> <span id="lgrey">is</span> <span id="mgrey">Posted Here</span></li>

While this is a bit messy, if I change the <span id="lgrey"> to <span class="lgrey">, it doesn't work.

Any idea why?

Thanks.

liorean
01-21-2004, 11:24 PM
The CSS syntax for simple selectors goes something like this:

namespace|element.class#id:pseudoclass::pseudoelement

Thus, you should use elm.class instead of elm#id if you want to address an element with a certain class.

oracleguy
01-21-2004, 11:55 PM
so just change this:

#lgrey {
color: #ccc;
}

to this:

.lgrey {
color: #ccc;
}

kraftomatic
01-22-2004, 03:34 PM
Thanks OG ...

So again, how would you define the difference between the use of "#" vs. "."?

liorean
01-22-2004, 04:54 PM
Hmm, maybe that would be best explaind this way: <http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#selectors>

Skyzyx
01-22-2004, 06:45 PM
You use # when you're referring to ID's, and you use . when you're referring to classes.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum