O'Reilly logo

HTML5 24-Hour Trainer by Mark Fletcher, Joseph W. Lowery

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. What Is CSS?

CSS, short for cascading style sheets, is the look-and-feel for HTML content. With CSS, you can change how text, images, and links appear quickly and easily, on a single web page or across and entire site — and what's more, the content's appearance can change based on the medium presenting it. CSS is a powerful technology, tightly intertwined with HTML in the building of modern websites. In this lesson, you learn the basics of CSS, including key concepts, where to store your CSS rules, and how to work with primary selectors.

UNDERSTANDING CASCADING STYLE SHEETS

Before CSS gained popularity, HTML pages were styled with tag attributes. For example, if you wanted to make a particular heading red, your tag would look like this:

<h1 color="red">Listen Up!</h1>

The problem with this approach is that the styling of the content is very tightly tied to the content itself. Though changing a single tag is easy enough, what if your design called for all <h1> tags to be red? If your color scheme changed so that every heading needed to be blue, you'd have to update every tag, one at a time. CSS provides a presentation layer independent of the content where you can easily make global formatting changes. This presentation layer brings numerous benefits, including:

  • Ease of modification: With CSS, you can style all the <h1> tags — or any other tags or custom selected content — in an entire site by changing values in one place.

  • Advanced design options: Current CSS implementations ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required