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 white 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. In fact, you can set different rules to control the appearance of every element in your page so that your pages start to look a lot more interesting.

As I have already mentioned, earlier versions of HTML used elements and attributes in the markup of the web page (just like the ones you have met already in the book) to control how a document should appear. However, the W3C (an organization that oversees the development of web technologies) decided quite a while back that the HTML and XHTML languages should no longer contain instructions that indicated how the document appears—rather that CSS should be used to control the appearance of web pages.

The W3C has actually released two versions of CSS. The properties and features you learn in this chapter are taken from CSS1 and CSS2 (as you probably guessed, CSS2 expanded upon CSS1). The W3C is also working on another update, which ...

Get Beginning Web Programming with HTML, XHTML, and CSS, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.