3.1. Applying CSS to HTML Documents

In Chapter 1, I introduced the three methods for applying style sheet properties to HTML documents. I will briefly review them here to jog your memory.

  • Inline styles : We can use the style attribute , which is available for the vast majority of HTML elements, to directly assign CSS properties to HTML elements.

    <h1 style="font-family: 'Comic Sans'; color: blue;">
      Welcome</h1>
    

    This method is best reserved for when you want to try out quickly one or more CSS properties to see how they affect an element. You should never use this method in a practical Web site, as it misses almost every advantage that CSS has to offer.

  • Embedded styles : We can use the <style> tag in the head portion of any HTML document to declare ...

Get HTML Utopia: Designing Without Tables Using CSS 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.