3.1. Why Do You Need CSS?

In the early days of the Internet, web pages consisted mostly of text and images. The text was formatted using plain HTML, using tags like <b> to make the text bold, and the <font> tag to influence the font family, size, and color. Web developers soon realized that they needed more power to format their pages, so CSS was created to address some of HTML's styling shortcomings.

3.1.1. Problems of HTML Formatting

One of the problems with using HTML for formatting is that it only offers a limited set of options to style your pages. You can use tags like <i>, <b>, and <font> to change the appearance of text and use attributes like bgcolor to change the background color of HTML elements. You also have a number of attributes at your disposal for changing the way links appear in your page.

Obviously, this feature set isn't rich enough to create the attractive web pages that your users expect and demand.

Another problem of HTML with a lot more impact on how you build your web pages is the way the styling information is applied to the page. By design, HTML forces you to embed your formatting in your HTML document, making it harder to reuse or change the design later. Consider the following example:

<p><font face="Arial" color="red" size="+1">
   This is red text, in an Arial type face and slightly larger than the default text
</font></p>

The problem with this code snippet is that the actual data (the text in the <p> element) is mixed with the presentation (the formatting ...

Get Beginning ASP.NET 3.5: In C# and VB 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.