Chapter 7. Cascading Style Sheets

Having learned how to structure the content of your documents using XHTML's wide variety of elements and attributes, you're now going to start making your pages look a lot more exciting.

You're going to learn how to use cascading style sheets (or CSS for short) to take control of the style of your pages, including the colors and size of fonts, the width and colors of lines, and the amount of space between items on the page. The cascading style sheets specification works by allowing you to specify rules that say how the content of elements within your document should appear. For example, you can specify that the background of the page is a cream color, the contents of all <p> elements should be displayed in gray using the Arial typeface, and that all <h1> elements should be in red using the Times New Roman typeface.

In this chapter you learn the following:

  • What makes up a CSS rule

  • How to place CSS rules within your document and how to link to an external CSS document

  • How properties and values control presentation of different elements within your document

  • How to control the presentation of text using CSS

  • How CSS is based on a box model, and how you set different properties for these boxes (such as width and styles of borders)

By the end of the chapter, you should be confidently writing CSS style sheets and should have learned many of the properties you can use to affect the presentation of any document using CSS.

In the next chapter, you will continue to ...

Get Beginning HTML, XHTML, CSS, and JavaScript® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.