View Full Version : linking to an external CSS file

Aug 31st, 2002, 10:39 AM
I read on W3.org that this is the proper way to link to an external CSS file in XML and XHTML, yet it does not seem to work.

<?xml-stylesheet href="css/test.css" type="text/css"?>
Should I stick with <link> ?

Aug 31st, 2002, 12:04 PM
don't know about XML, but on my XHTML pages I use either this:

<style type="text/css" media="all">@import "/style.css";</style>

or this:

<link rel="stylesheet" media="all" href="/style.css" type="text/css" />

to link to css files

Aug 31st, 2002, 04:10 PM
That is the correct way, and works fine in IE5+, Mozilla, and Opera.

Aug 31st, 2002, 06:45 PM
The <?xml-stylesheet?> processing instruction was intended to be only a temporary measure (though it appears to be still current).


Alex Vincent
Sep 1st, 2002, 10:34 PM
John, do you have a testpage you can show us?

The mime-type may be affecting it a great deal. For instance, an XHTML file served as text/html will not process stylesheets from <?xml-stylesheet ?>.

Sep 3rd, 2002, 11:14 PM
Yeah I figured that out. .xml supports <?xml-stylesheet ?> where .htm wont