CSS Validating

Soldato
Joined
18 Oct 2002
Posts
9,044
Location
London
I get this when trying to use http://jigsaw.w3.org/css-validator


Errors
URI : xxx.css
Line: 7 Context : ���
Parse Error - * {margin:0;padding:0;}

Warnings
URI : xxx.css
Line : 26 (Level : 1) You have no background-color with your color : .nv-may
Line : 27 (Level : 1) You have no background-color with your color : .nv-ill
Line : 28 (Level : 1) You have no background-color with your color : .nv-port
Line : 29 (Level : 1) You have no background-color with your color : .nv-pro
Line : 30 (Level : 1) You have no background-color with your color : .nv-news
TIMES 20!


Not sure about the error, I thought this was a standard thing?

As for the warnings, I guess it's not important, but I could go through and add some background#. Just seems like extra wasted bytes though..

Any thoughts? :)
 
Strange, I can't recreate that error with that line of CSS.

As for the background color warnings, you can set each of those classes background-color property to inherit.
 
Are you sure the parse error is not related to something before or after that? It mentions the parse error is on line 7; perhaps you are required to put that rule right at the top of your stylesheet (which you should be doing anyway, aside from any lines lost to commenting or white space)?

As for the background-color warnings, you are being advised on that because there is a chance that something erroneous could happen behind the element and the text would therefore become unreadable. Setting a correct background-color (and not just background-color: inherit;) is therefore a failsafe to ensure the text is readable no matter what happens. It does seem like a lot of wasted bytes, granted, but if you want to carry that CSS validation badge...

I'm sure Augmented will come along with some words of wisdom soon enough :)
 
KingAdora said:
As for the warnings, I guess it's not important, but I could go through and add some background#. Just seems like extra wasted bytes though..
I believe it's an accessibility issue (hence the "(Level: 1)"), rather than one of validation, and yes only there to warn you of potential issues. Should, for example, a user have a browser that uses a default background colour of black instead of the typical transparent/white, all your rules with black text may end up not being readable, just as Al Vallario said. I personally wouldn't worry about it too much, and like all things accessibility, you need to really assess it manually to see if it needs attention.

As for the parser error, I'm not sure. The only thing I can think it might be is that the line of the file was copied and pasted from somewhere else? Perhaps an erroneous character there (line ending or carriage return, for example) doesn't match the stylesheet's declared encoding it might give the validator grief. Stab in the dark, but maybe try deleting the whole line and writing it out again.

/edit - are you perchance using Notepad?
 
Last edited:
Thanks for the advice guys!

However, I tried again but this time:
1. validating the css file directly
2. re-writing the line to line 1 (before I had comments up there)


Line: 1 Context : ���
Parse Error - ���*{margin:0;padding:0}

Those question marks are actually square boxes [] :confused:
Real weird one. Maybe it's because I'm currently hosting it on a server at home. W2003.

Edit: using DW8
 
Now I'm confused. I did the same thing in notepad. No difference. Went back to DW, saved it - now it works.

One of those things I guess! How annoying. Thanks for the help though :)
 
Back
Top Bottom