122 CHAPTER 5 DISPLAYING (Web server) XML USING CSS
122 CHAPTER 5 DISPLAYING XML USING CSS these versions. I ve also included support for the Macintosh IE and Safari web browsers where possible. As with the previous chapters, you can download the resources for this chapter from the Source Code area of the Apress web site (http://www.apress.com). Let s start with a quick recap of CSS. Introduction to CSS Since the early days of printing, stylesheets have provided instructions about which font family and size to use when printing a document. You can use CSS to provide styling information for web documents. A CSS stylesheet is effectively a text document saved with the .css extension. Why CSS? When you include presentation elements within an XHTML page, the content can easily get lost within the style or presentation rules. The following benefits arise from separating the content from the style and using a stylesheet to indicate how a document can be presented visually: A single stylesheet can alter the appearance of multiple pages, meaning that you don t need to edit each individual page to make changes. Different stylesheets offer alternative views of the same content. The content is simpler to author and interpret because it doesn t include presentation information. Web pages load more quickly because a stylesheet is downloaded once and cached. You can then reuse it throughout the site. The pages themselves are smaller because they no longer contain styling information. A CSS document contains style rules that apply to the elements of a target document, indicating how the content of those elements should be rendered in a web browser. CSS Rules CSS is based on rules that govern how the content of an element or set of elements should be displayed. You ll see how to specify which elements to style a little later when I discuss the CSS selectors. Here s an example of a CSS rule: h1 {color:# 2B57A1;} The rule is split into two parts: the selector (h1) and the declaration (color:# 2B57A1). The selector shows which element or elements the declaration should apply to while the declaration determines how the element(s) should be styled. In this example, all