X hits on this document

420 views

0 shares

1 downloads

0 comments

32 / 142

Chapter 5. Rendering cascading style sheets

XML

with

Introduction

Cascading style sheets (CSS) represent a method for rendering XML files into a more human presenta- tion. CSS files exemplify a method for separating presentation from content.

CSS have three components: layout, typography, and color. By associating an XML file with a CSS file and processing them with a Web browser, it is possible to display the content of the XML file in an aes- thetically pleasing manner.

CSS files are made up of sets of things called selectors and declarations. Each selector in a CSS file cor- responds to an element in an XML file. Each selector is then made of up declarations -- standardized name/value pairs -- denoting how the content of XML elements are to be displayed. They look something like this: note { display: block; }.

Here is a very simple XML document describing a note:

<?xml-stylesheet type="text/css" href="note.css"?> <note>

<para>Notes are very brief documents.</para> <para>They do not contain very much content.</para> </note>

The first thing you will notice about the XML document is the addition of the very first line, an XML processing instruction. This particular instruction tells the application reading the XML file to render it using a CSS file named note.css. The balance of the XML file should be familiar to you.

If I wanted to display the contents of the note such that each paragraph were separated by a blank line, then the CSS file might look like this:

24

Document info
Document views420
Page views426
Page last viewedTue Dec 06 22:07:13 UTC 2016
Pages142
Paragraphs3126
Words34660

Comments