Working with Cascading Style Sheets (CSS)

As we have discussed, the use of CSS can add a great deal to our web pages in terms of implementing style. We can easily add elements and control the 'presentation' using fairly easy to understand methods. As we've discussed in class, in the not-to-distant future, all style features of web pages will probably be controlled through the use of CSS.


The Advantages

The advantages of using external, internal or inline style are many. One of the main reasons that the idea of using CSS was first developed was to separate the content (what is displayed) of web pages from the presentation (how it appears) of the web page. Also, HTML coding methods can make implementing stylistic features very repetitive and time consuming. So the use of CSS was developed, and they present us with the following benefits:


The Disadvantages

It turns out that there are no 'major' disadvantages to using CSS to control the style of our pages. This doesn't mean there aren't any concerns. Perhaps the most important problem worth mentioning is that some browsers implement CSS in different ways, and some have 'quirks' in which they use CSS info in a way that might not display elements exactly as expected. This requires that the user of CSS should test their pages on as many different browsers as is possible to make sure their pages are implemented as desired.


Why Aren't CSS Standard Usage?

There are several things holding back the usage of CSS as a standard feature of all web pages. One was the problem mentioned above, namely browser specific 'quirks' that led some to not trust CSS to properly implement pages. The main reason, however, is the simple fact that CSS style elements use different property names than the attributes common to HTML. For example, the 'align="center"' attribute in HTML becomes 'text-align:center;' in CSS. As a result, long-time users of HTML had to learn a whole new set of code and a very different method of implementation. As time progresses, and as a new generation of programmers initially trained in the use of CSS joins the work force, the use of CSS to implement style will probably become the standard for all web pages.


Implementation of CSS

Incorporating the use of CSS into our web design turns out to involve a choice. There are three methods for controlling style on our pages using CSS: External style sheets, Internal ("embedded") style sheets, and Inline ("local") style sheets. There are some complexities as to how these interact with each other, but the main ideas are the following:

External Style Sheets:

Internal Style Sheets:

Inline Style Sheet: