O'Reilly logo

Beginning XML, 4th Edition by Andrew Watt, David Hunter, Linda McKinnon, Joe Fawcett, Eric van der Vlist, Jon Duckett, Danny Ayers, Jeff Rafter

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17. Cascading Style Sheets (CSS)

This chapter examines Cascading Style Sheets (CSS) as a means of styling XML documents for use on the Web. You may well have already used CSS with HTML or XHTML. Dealing with other XML document types, however, requires some different techniques, which are covered in this chapter.

You'll see XHTML in the next chapter, but for the time being you only need to know that XHTML documents can be styled like HTML documents. Styling XHTML and HTML documents is so similar that this chapter uses the term "(X)HTML" to represent "HTML or XHTML."

Even when you remove stylistic markup from an (X)HTML document, the browser still knows how to display elements, such as tables, lists of different levels of headings, and so on. In other XML vocabularies, you won't even have this most rudimentary help with layout. After all, a <table> element in your XML vocabulary might be used to describe a piece of wood with four legs. Considering that a browser won't know how any of the elements in your XML vocabulary need to be displayed, you have a lot more work to do when styling XML documents with CSS than (X)HTML documents.

If you know that your XML documents will be displayed on the Web, some of the points you learn in this chapter might even affect the way in which you write your vocabulary or schema. For example, by the end of the chapter, you will understand why CSS is much better suited to displaying element content than attribute values.

In this chapter you will learn ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required