22.04.2013 Views

HTML, XHTML & CSS

HTML, XHTML & CSS

HTML, XHTML & CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 9: Introducing Cascading Style Sheets<br />

For example, these three style rules set the colors for first-, second-, and<br />

third-level headings:<br />

h1 {color: teal;}<br />

h2 {color: maroon;}<br />

h3 {color: black;}<br />

The <strong>CSS</strong> specification lists exactly which properties you can work with in<br />

your style rules and different values they can take. Most are pretty selfexplanatory<br />

(color and border, for example). See “What you can do with<br />

<strong>CSS</strong>,” earlier in this chapter, for a quick rundown of properties included in<br />

the <strong>CSS</strong>2 specification.<br />

Style sheets override a browser’s internal display rules; your style declarations<br />

affect the final appearance of the page in the user’s browser. This<br />

means that you can control how your content looks and create a more consistent<br />

and appropriate experience for visitors.<br />

For example, the following style rules specify font sizes (in percentages, relative<br />

to the base font) for first-, second-, and third-level headings:<br />

h1 {font-size: 300%;}<br />

h2 {font-size: 200%;}<br />

h3 {font-size: 150%;}<br />

Figure 9-1 shows a simple <strong>HTML</strong> page with all three heading levels (plus<br />

some body text) without the style sheet applied. The browser uses its default<br />

settings to display the headings in different font sizes.<br />

Figure 9-1: An <strong>HTML</strong> page without style specifications.<br />

135

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!