PDA

View Full Version : why is this CSS not valid ?


brothercake
01-20-2003, 08:50 PM
When I ran a stylesheet through the w3c's validator it flagged up loads of things like this

div#column_right {


What's wrong with that ? And if that's not good, how else can I say the same thing?

cg9com
01-20-2003, 09:28 PM
trying different options i found out how annoying it was that whenever you hit back the CSS textarea resets to blank lol

anyway i think its the _ ???
i couldnt figure out anything but ill keep trying

Catman
01-20-2003, 09:29 PM
From what I've read: Apparently they were unclear in the original specification of CSS1, so some browsers supported underscores in IDs and some did not. Supposedly this was supposed to be fixed in the validator sometime in 2001, but apparently that never happened.

I'd guess if it works in browsers you intend to support, it's not anything to worry about (since it's an error in the validator). On the other hand, if you intend to include browsers which do not support the underscore, you could mimic JavaScript's handling of hyphenated attribute names:

div#columnRight {

MrDoubtFire
01-20-2003, 11:46 PM
When I ran a stylesheet through the w3c's validator it flagged up loads of things like this

div#column_right {

What's wrong with that ? And if that's not good, how else can I say the same thing?


Ok you said, "loads of things like this", so this is not the only problem...? Perhaps you could post the entire stylesheet and/or the validation page and all the errors.

I don't think there's anything wrong with what you posted unless you were running the pages in strict mode. Having said that though, I've moved towards using capital markers like Catman posted [columnRight] because of ease of use but not because it gave any advantage in terms of grammar and errors.

MrDF

brothercake
01-21-2003, 02:21 AM
when i said "loads of things" i meant lots of declarations in that "element#underscored_classname" format.

So the explanations here make sense. thanks :)