External CSS and HTML 2.0

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have been running tests on various doctypes and
found something interesting.

I set up a test page using this doctype...

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 1//EN">

...and put this in the head:

 <link rel="stylesheet" type="text/css" href="http://www.example.com/test.css ">

The page failed the W3C validator.  Changing the above to...

 <link rel="stylesheet" href="http://www.example.com/test.css ">

...allowed the page to validate.

I already tell the browser what type of document test.css
is in my .htaccess file:

 AddType 'text/css; charset=US-ASCII' .css
 AddCharset US-ASCII .css
 AddLanguage en-US .css

I repeated the test with  HTML 4.01 strict and XHTML 1.1
pages (making the other changes needed) and it still validated.

Other than the usual Internet Explorer choking on XHTML 1.1
served as application/xhtml+xml, the HTML 2.0, HTML 4.01 strict
and the XHTML 1.1 test pages are all following the directives
in the CSS file just fine.  The only quirk I found was that the
W3C CSS Validator couldn't find the CSS from the HTML/XHTML
file (but it validated when I pointed it at the CSS file).

Is there any good reason why that type="text/css" is found
in every example of using an extenal CSS that I can find?

Guy Macon <http://www.GuyMacon.com/ Guy Macon <http://www.GuyMacon.com/
Guy Macon <http://www.GuyMacon.com/ Guy Macon <http://www.GuyMacon.com/
Guy Macon <http://www.GuyMacon.com/ Guy Macon <http://www.GuyMacon.com/
Guy Macon <http://www.GuyMacon.com/ Guy Macon <http://www.GuyMacon.com/

Re: External CSS and HTML 2.0

Guy Macon wrote:
Quoted text here. Click to load it

Because HTML 2.0 didn't support the type attribute. No problem there, right?

Quoted text here. Click to load it


Fascinating, perhaps, but wholly unrelated to HTML validity.

Quoted text here. Click to load it

The type="text/css" is required for embedded style information as per
http://www.w3.org/TR/html401/present/styles.html#h-14.2.3 . For external
style sheets, the requirement is not so clear, but perhaps you will be
satisfied with the text (second bulleted item) at
http://www.w3.org/TR/html401/present/styles.html#specifying-external ,
in case you haven't read it already?

"This allows the user agent to avoid downloading a style sheet for an
unsupported style sheet language."

I have no idea what other languages a stzle sheet might be in. Klingon?

Quoted text here. Click to load it

You know, this really annoys me every time I see you do it.

Trying to be a nice guy, if I may use that expression.

Re: External CSS and HTML 2.0

John Hosking wrote:
Quoted text here. Click to load it

I believe that it is related to HTML validity. From:

|Authors must specify the style sheet language of style
|information associated with an HTML document.
|The default style sheet language may also be set with HTTP
|headers. The above META declaration is equivalent to the
|HTTP header:
|Content-Style-Type: text/css

...which is, of course what putting

AddType 'text/css;  .css

in the .htaccess file does on Apache servers.

My take on this (and, it seems, the take of the authors of the
DTD that the w3C HTML Validator uses for HTML 4.01 Strict) is
that the requirement is to specify that the style sheet is
text/css before the browser downloads it.  This can be (and
usually is) done with [ type="text/css" ] in the link in the
HTML docoment that calls the external style sheet, but it looks
tp me that specifing that the style sheet is text/css by serving
the stylesheet with a [ Content-Style-Type: text/css ] HTTP
header is also valid.


Microsoft Windows has detected an outdated internal organ.

The Microsoft Transplant Wizard is preparing your body
for the installation of a new kidney. Please wait...

Do you wish to make a backup copy of your existing kidney? [Y/N]

Installing kidney...10...20...30...40...50...60...70...

       "ERROR 31337:  Insufficient space
       in abdominal cavity. Delete liver
       to create additional organ space?"


Re: External CSS and HTML 2.0

Guy Macon wrote:
Quoted text here. Click to load it

Okay, I see your point. I was trying to say that the HTML itself is
unaware what might be in the .htaccess file and doesn't know or care
even what headers are sent. The HMTL parser has to know the encoding of
the HTML document, but won't otherwise care about headers or Apache
configurations. The CSS file has to be locatable and readable when it
comes time to *render*, but the HTML and its parsing are separate.

But I see that the W3C doc you point to has a bit of a leak in it.
Ostensibly describing what's in an HTML document and what it means, it
starts pointing outside the document at HTTP headers (and their
lieutenants, the META declarations).

So whatever the limitations of the validator[1], if you've declared a
default style sheet language[2] via any legal method, you're in good shape.

[1] Did you say you got valid results for HTML 4.01 strict served
without the [ type="text/css" ] in the link and without the [ AddType
'text/css;  .css ] in the .htaccess file? That is, without *any*
declaration of the type?

[2] 'Ts hardly a language, is it?

Quoted text here. Click to load it

Thanks for fixing your delimiter. I had to do some work to quote your
sig. :-)

Quoted text here. Click to load it

Longer, but funnier. From my experience, I'd expect that when one clicks
"OK", another dialog comes up that says

Deleting liver can cause problems and lead to system instability.
Are you sure you want to delete liver, or do you want to abort the
deletion (recommended)?

               [Yes]     [No]    [Cancel]

My funny .sig is in the shop for maintenance.

Site Timeline