Attaching External Style Sheets

CSS2 is the current standard for allowing authors to specify style information in web documents. CSS Contains information about the size, placement, color and other visual aspects of HTML entities. The current CSS specifcation is CSS2 which is a superset of CSS1 and allows designers to specify style for various media, such as print.
One of the first things you will find about CSS styles is that they can be defined in a number of places. By specifing styles via an external file designers can use one or several sheets across a whole site. Minor sitewide design changes are then greatly simplified by making the changes in a single file, or stylesheet. The following are the two methods of “attaching” a stylesheet file named mystyle.css


I provide some more examples of multpile style sheets being imported, but before you flip over to that, I should give you the official links to HTML, XHTML and CSS because those are the standards I write about and (try to) design to. The official standards body for these languages is The W3 Consortium –
In either case, a link or import via style element, the attribute type specifies the language of the style sheet. It is always “text/css” although it could be some other language in the future without breaking the modular nature of web documents. (Of course CSS works for pure XML too, so its unlikely to be unseated.)
When using the “rel” attribuite in a link tag, and author can also specify an alternative style sheet by setting the value of that attribute to “alternate” should force a choice on users. I tested this for the article you’re reading and IE6.0 does not seem to support this part of the standard. So, for cross browser compatibility we usually use the @import method to specify more than one style sheet. (I always wondered why we did it that way. )
The idea of defining styles in an external sheet could be further modularized by grouping certain kinds of styles, such as table formating, into individual files. Using the import method, this is accomplished as follows:

Whether you choose to write your pages utilizing multiple sheets or only a single style sheet, sites that are written to standards will survive the test of time bettter than those that are written to the “anything that looks right is OK” standard. Those sites seem to break almost every time the powers that be release a new browser. With the exception noted above, it’s my recent experience that the browsers become more and more standards compliant with every successive release.

Comments are closed, but trackbacks and pingbacks are open.