Style Sheets (XSL, CSS)
January 3, 2000
Essentially, style sheets are written instructions explaining
how a certain document should be displayed. Style sheets
are as old as the printing press and probably older.
Frank Boumphrey, in "Style Sheets for HTML and XML", puts
style sheets into their historical perspective as such....
"In the days of manual type-setting, style
sheets were nothing more than a set of written instructions
from the publisher to the printer telling the printer what
kind of style to use when printing up the publisher's
manuscript. Traditionally, the editor would deliver
a "marked-up" manuscript full of terse notations like dele
and stet. The printer would then consult the style sheet of
that particular publishing house for a range of specifications.
These specifications would encompass such details as what
size the pages were to be, what size and family of font to
use for chapter titles, sub-headings, body text, and so on.
Plus, how much leading to put between the lines, what
margins to leave, and whether, and by how much, to indent the
paragraphs."
As we have said above, HTML is a markup language that helps
define how the web browser should display a given HTML marked
up document.
However we have also said that it is dangerous to embed too
much style into your HTML code. What happens when the
company decides to change its corporate font? What about the
company colors. If you have hardcoded style throughout your
website, it is very difficult to change.
This is where style sheets come into play. Style sheets allow
you to specify generic styles which apply broadly but are
located uniquely. In other words, a single style sheet can
be referenced by every web page on a site (or every component
on a page if the style sheet is defined in the page header).
If you want to change an aspect of style such as color,
font, spacing, or whatever, you simply change the style sheet
and that change is propagated to every page that references
the style sheet.
There are several languages/specifications to help you create
style sheets for your site but the two most popular are CSS
(Cascading Style Sheets) and XSL (eXtensible Style Sheet
Language) where CSS certainly has market
share.
CSS works using the <STYLE> tag and allows you to
specify styles using scripting languages like VBScript.
Consider the following small example:
<HTML>
<HEAD>
<TITLE>Test</TITLE>
<STYLE>
<!--
TD {FONT-FAMILY: "TimesRoman", "SANS-SERIF";}
BODY {FONT-FAMILY: "ARIAL", "SANS-SERIF";}
-->
</STYLE>
</HEAD>
<BODY>
This is in Arial
<TABLE>
<TR>
<TD>This is in TimesRoman</TD>
</TR>
</TABLE>
</BODY>
</HTML>
As you might imagine, BODY text will by displayed as ARIAL
and Table cell data will be displayed as Times Roman font.
Additional Resources:
Disadvantages of XML
Introduction to the Web Application Development Environment (Tools)
|