3.2 USING CSS

Style sheets are thus templates, containing rules on how to apply styles to content. An understanding of the Document Object Model (DOM) model will make usage of CSS clearer. There is a separate section on DOM as part of JavaScript and the reader is encouraged to refer both these sections in parallel, if required. However, the reader may choose to mull over the topic of CSS and then revisit this chapter after DOM has been covered.

There are three ways to associate styles with content. They are inline, embedded and linked. The last option is the ideal method that is recommended in the interest of best practices for web development.

Styles can be used along with HTML (recall that HTML is used interchangeably with XHTML), applied directly ...

Get Web Technology: Theory and Practice now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.