Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development

  • Print
  • + Share This


Stylesheets are becoming increasing important in HTML because, in HTML 4, many built-in style features such as the <CENTER> element have become deprecated (declared obsolete) in favor of stylesheets. However, most HTML programming ignores stylesheets entirely.

The story is different in XML, however. In XML, you create your own elements, which means that if you want a browser to display them, you have to tell it how. This is both good and bad: good because it allows you to use the powerful Cascading Style Sheet (CSS) and Extensible Styleheet Language (XSL) specifications to customize the appearance of your XML elements far beyond what's possible with standard HTML, but bad because it can demand a lot of additional work. (One way of getting around the necessity of designing your own stylesheets is to use an established XML language that has its own stylesheets.)

All this is to say that XML defines the structure and semantics of the document, not its format; if you want to display XML directly, you can either use the default presentation in Internet Explorer or use a stylesheet to set up the presentation yourself.

Two main ways exist for specifying a stylesheet for an XML document: with CSS and with XSL, both of which I'll dig into in this book. CSS is popularly used with HTML documents and is widely supported. Using CSS, you can specify the formatting of individual elements, create style classes, and set up fonts, colors, and even placement of elements in the page.

XSL, on the other hand, is ultimately a better choice to work with XML documents because it's more powerful (in fact, XSL stylesheets are themselves well-formed XML documents). XSL documents are made up of rules that are applied to XML documents. When a pattern that you've specified in the XSL document is recognized in the XML document, the rules transform the matched XML into something entirely new. You can even transform XML into HTML this way.

Whereas CSS can only set the format and placement of elements, XSL can reorder elements in a document, change them entirely, display some but hide others, select styles based not just on elements but also on element attributes (XML elements can have attributes just as HTML elements can, and I'll introduce them in the next chapter), select styles based on element location, and much more. There are two ways to approach XSL: with XSL transformations and XSL formatting objects. We'll take a look at both in this book.

Here are some good online resources for stylesheets:

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.