Skip to Content
Web Design in a Nutshell, 3rd Edition
book

Web Design in a Nutshell, 3rd Edition

by Jennifer Robbins
February 2006
Intermediate to advanced
826 pages
63h 42m
English
O'Reilly Media, Inc.
Content preview from Web Design in a Nutshell, 3rd Edition

Inline Styles

You can add style information to an individual element by using the style attribute within the HTML tag for that element. The value of the style attribute is one or more standard style declarations, as shown here:

    <h1style="color: red">This Heading will be Red</h1>

    <p style="font-size: 12px; font-family: 'Trebuchet MS', sans-serif">
    This is the content of the paragraph to be set with the
    described styles.</p>

Note that if the style attribute uses double quotation marks as shown, quoted values within the list (such as the font name “Trebuchet MS” in the example) must use single quotation marks. The reverse is also valid: if the document uses single quotes for attributes, then contained quoted values require double quotes.

Although a perfectly valid use of style information, inline styles are equivalent to the font extension to HTML in that they pollute the document with presentation information. With inline styles, presentation information is still tied to individual content elements, so any changes must be made in each individual tag in every file. Inline styles are best used only occasionally to override higher-level rules. In fact, the style attribute has been deprecated in XHTML 1.1 and does not appear in other XML languages.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Responsive Web Design with HTML5 and CSS3

Beginning Responsive Web Design with HTML5 and CSS3

Jonathan Fielding

Publisher Resources

ISBN: 0596009879Errata Page