validating CSS

Associate
Joined
24 Aug 2004
Posts
343
Location
UK
I have a XHTML 1.0 Transitional page that passes validation, but the stylesheet it uses doesnt quite validate as it says:

No error or warning found
To work as intended, your CSS style sheet needs a correct document parse tree. This means you should use valid HTML.

Can anyone enlighten me on this?
Thanks

Here is the Style sheet:
Code:
#container
{
width: 90%;
margin: 10px auto;
background-color: #b9d3ee;
color: #333;
border: 1px solid #000088;
line-height: 130%;
}

#top
{
padding: .5em;
background-color: #6699cc;
color: #333;
border-bottom: 1px solid #000088;
}

#top h1
{
padding: 0;
margin: 0;
}

#leftnav
{
float: left;
width: 160px;
margin: 0;
padding: 1em;
}

#content
{
margin-left: 200px;
border-left: 1px solid #000088;
padding: 1em;
max-width: 36em;
background-color: #cae1ff;
color: #333;
}

#footer
{
clear: both;
margin: 0;
padding: .5em;
color: #333;
background-color: #6699cc;
border-top: 1px solid #000088;
}

#leftnav p { margin: 0 0 1em 0; }
#content h2 { margin: 0 0 .5em 0; }

and here is the valid xhtml (i know its not very interesting at present!)
Code:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>Steve</title>
<link rel="stylesheet" href="mystyles.css" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<div id="container">
<div id="top">
<h1>Header</h1>
</div>
<div id="leftnav">
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut.
</p>
</div>
<div id="content">
<h2>Subheading</h2>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</p>
<p>
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</p>


  <p>
    <a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10"
        alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
  </p>

</div>
<div id="footer">
Footer
</div>
</div>

</body>
</html>
 
Thanks for the advice, what has me confused it my XHTML gives me a button to show that it has validated. it doesnt do that with the CSS :confused: (i know i cheat to get the button but i would like to get it presented to me as this is more of a learning exercise.

Thanks
 
Augmented said:
because it has no URI to create a custom link.

Thats exactly what i needed, sometimes those simple things are staring you in the face yet you still cant see them! I uploaded the file and am presented with the button by the validator.

Augmented said:
code should always be valid and one shouldn't need a button to prove it :).

I totally agree, this for me is about the learning experience, and so it was just a frustrating little thing that was holding me up. i was doubting my code because of it. now that i know its all good i can continue!

Thanks for all your help Augmented! much appreciated.
 
Back
Top Bottom