CSS to the Rescue
Of course, the problem of polluting HTML with presentational markup was not lost on the World Wide Web Consortium (W3C), which began searching for a quick solution. In 1995, the consortium started publicizing a work-in-progress called CSS. By 1996, it had become a full Recommendation, with the same weight as HTML itself. Here’s why.
Rich Styling
In the first place, CSS allows for much richer document appearances than HTML ever allowed, even at the height of its presentational fervor. CSS lets you set colors on text and in the background of any element; permits the creation of borders around any element, as well as the increase or decrease of the space around them; lets you change the way text is capitalized, decorated (e.g., underlining), spaced, and even whether it is displayed at all; and allows you to accomplish many other effects.
Take, for example, the first (and main) heading on a page, which is usually the title of the page itself. The proper markup is:
<h1>Leaping Above The Water</h1>
Now, suppose you want this title to be dark red, use a certain font,
be italicized and underlined, and have a yellow background. To do all
of that with HTML, you’d have to put the
h1 into a table and load it up with a ton of other
elements like font and U. With
CSS, all you need is one rule:
h1 {color: maroon; font: italic 2em Times, serif; text-decoration: underline;
background: yellow;}That’s it. As you can see, everything you did in HTML can be done in CSS. There’s no need ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access