Need of Style Sheets
Style sheets are a set of rules that describe the appearance of data in an XML document.
XML was inspired by the problems posed by presentational markup. Presentational markup does not describe data, it defines the appearance of data. In a document, if you had to change all proper nouns from bold to italics, you would have to do it manually for each proper noun. Presentation markup failed to provide same look and feel across multiple devices such as computers, Personal Digital Assistant (PDA) devices, and cell phones.
Style sheets and XML solve these problems. XML describes data. Style sheets define the appearance of data. However, both XML and style sheets are defined in separate files.
Fig: Formatting Document with Style Sheet.
Various Style Sheets
There are several style sheets available. However, following two are the most popular style sheets:
- Cascading Style Sheets (CSS): CSS allows you to control the appearance of data in HTML and XML documents by providing various properties to define:
1. Position and size of data to be displayed
2. Foreground and background color of data
3. Font to be used to display data
4. Spacing between data
- Extensible Style Sheet (XSL): XSL is a style sheet language used to define the appearance of data contained only in XML documents. However, it also allows you to transform XML documents.