Why use CSS?
The proper use of CSS to style a page has many good points and a few drawbacks. The good points are:
-
The code looks cleaner. The use of CSS allows to separate content from design, structure from style, semantics from presentation. As a consequence, the code is easier to read and to manipulate for both people and machines.
-
The page is lighter. CSS style rules can define the style for a plurality of elements. If CSS is not used, each of these elements should be styled separately inside the document (with the same style). Hence, redundancy is reduced. This is relevant when the bandwidth is limited or the host charges based on bandwidth usage. Less code means less cost and higher speed.
-
Redesign becomes easy. In order to change the style of a class of elements you just have to change the appropriate rule in the stylesheet, without modifying the content document at all. Both page authors and users can take advantage of this feature. In particular, users can define their own favorite style. This enhances accessibility.
-
Better results in search engines. The search engine robots want to find out how relevant the webpage is as fast as possible. Less and cleaner code will probably give your page a proper ranking.
The main
drawbacks are:
- Difficulty with adoption. Many web browsers have been lazy to implement CSS specifications or have implemented them incorrectly. Authors had to resort to using hacks and workarounds to obtain consistent results across web browsers. Moreover, CSS level 3, which was started in 1998, is still under development as of 2006.
-
Selectors have limited power. The expressive power of CSS selectors is far away from that of XPath. In particular, selectors are unable to ascend the document tree.
-
Lack of orthogonality. Multiple properties often end up doing the same job.