CSS and Documents by Eric A. Meyer

CSS and Documents by Eric A. Meyer

Author:Eric A. Meyer [Eric A. Meyer]
Language: eng
Format: epub, pdf
Tags: COMPUTERS / Web / Page Design
ISBN: 9781449342463
Publisher: O'Reilly Media
Published: 2012-09-27T16:00:00+00:00


Warning

Older versions of Internet Explorer for Windows do not ignore any @import directive, even those that come after other rules. Since other browsers do ignore improperly placed @import directives, it is easy to mistakenly place the @import directive incorrectly and thus alter the display in other browsers.

HTTP Linking

There is another, far more obscure way to associate CSS with a document: you can link the two together via HTTP headers.

Under Apache, this can be accomplished by adding a reference to the CSS file in a .htaccess file. For example:

Header add Link "</ui/testing.css>;rel=stylesheet;type=text/css"

This will cause supporting browsers to associate the referenced style sheet with any documents served from under that .htaccess file. The browser will then treat it as if it were a linked style sheet. Alternatively, and probably more efficiently, you can add an equivalent rule to the server’s httpd.conf file:

<Directory /path/to/ /public/html/directory> Header add Link "</ui/testing.css>;rel=stylesheet;type=text/css" </Directory>

The effect is exactly the same in supporting browsers. The only difference is in where you declare the linking.

No doubt you noticed the use of the term “supporting browsers.” As of early 2012, the widely used browsers that support HTTP linking of style sheets are the Firefox family and Opera. That restricts this technique mostly to development environments based on one of those browsers. In that situation, you can use HTTP linking on the test server to mark when you’re on the development site as opposed to the public site. It’s also an interesting way to hide styles from the WebKit and Internet Explorer families, assuming you have a reason to do so.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.