Setting the default style sheet language on your Web site

Part of Tutorials

Author(s) and publish date

By:
Published:
Skip to 4 comments

Very often Web creators are using an external style sheet, or a style element to add style information to their html pages. By doing, we specify what is the style language used in the Web page. For example using the `link` element.

<link href="cute.css" rel="stylesheet" type="text/css"/>

But if your page is using the style attribute, the user agent may not know what is the language used for styling. This is a principle of orthogonality. A company could launch a user agent with a new style language and a new mime-type. It will be difficult to impose and ensure interoperability because of the deployment base, but it is still possible.

If you want to set up a default style sheet language for your Web site, there are a few choices. You can use a meta name in each of your page:

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

or you can specify an HTTP header:

Content-Style-Type: text/css

With Apache http server 2.0, you can use mod_headers and mod_setenvif in the general configuration file or at a directory level in .htaccess:

SetEnvIf response Content-Type [text/html|application/xhtml+xml] html-content=1
Header add "Content-Style-Type: text/css" env=html-content

PS: mod_headers and mod_setenvif are not activated in the base configuration of Apache httpd, you have to activate them.

Examples given for xhtml documents served as application/xhtml+xml

Related RSS feed

Comments (4)

Comments for this post are closed.