Forum Moderators: open

Message Too Old, No Replies

HTML Strict and Styles

CSS wont show unless doctype is commented out

         

ukgimp

10:09 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have all my style in the head whilst playing with the look, the page validates to html strict, but for the CSS to work (even the simple stuff like altering H1) I have to comment out the doctype and it works.

I have tried to put all the styles in an external sheet and the problem persists.

Is there an issue that I dont know about.

Cheers

grahamstewart

11:01 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Weird...

Okay so the HTML validates but does your CSS?

So you have a Content-Style-Type tag?

<meta http-equiv="Content-Style-Type" content="text/css">

BlobFisk

11:04 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm - this is very strange, can't say that I've ever seen anything like it before.

grahamstewart - that meta tag is a new one on me! Is it as a supplement to the type="text/css" in the stylesheet link/import call? Or is it mandatory?

ukgimp

11:13 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I feel rather sheepish. I was writing an expansion post, and going through the variables. I have a capital letter discrepency. Weird though as it works without the doctype.

Sorry for being a muppet :)

grahamstewart

11:34 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, without a doctype some browsers can be remarkably forgiving - you'd be surprised what works (multiple <head>s and <body>s for instance!)

BlobFisk: In theory stylesheets can be written in any language you like. So a meta tag (or HTTP header) should be used to define what style language you are using.

Authors must specify the style sheet language of style information associated with an HTML document....Documents that include elements that set the style attribute but which don't define a default style sheet language are incorrect.

-from [w3.org...]

BlobFisk

11:36 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Very interesting - thanks for the reply and the link!

tedster

11:38 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From that W3C page:

1. If any META declarations specify the "Content-Style-Type", the last one in the character stream determines the default style sheet language.

2. Otherwise, if any HTTP headers specify the "Content-Style-Type", the last one in the character stream determines the default style sheet language.

3. Otherwise, the default style sheet language is "text/css".

I choose #3. But seriously, I didn't realize there was a requirement here. Lucky for me I haven't ventured outside the default area.

BlobFisk

12:21 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I never stray away from text/css either - does anyone here use another language?

Since the default is text/css, is there a need to include the meta tag, if your stylesheet is written in text/css?

grahamstewart

12:33 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well the spec says that "text/css" is the fallback default value, but it seems to suggest that we should avoid relying on that fact...

Documents that include elements that set the style attribute but which don't define a default style sheet language are incorrect.
Authoring tools should generate default style sheet language information (typically a META declaration) so that user agents do not have to rely on a default of "text/css".

If your existing sites don't have then I would panic too much. But its one to note for the future.

If you do want to specify it for your existing sites then it would probably be easier to do so in your HTTP headers (i.e. by using <Header> directive in .htacess)