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

Name

div

Synopsis

    <div>...</div>

Attributes

Core (id, class, style, title), Internationalization, Events

Deprecated attributes

align="center|left|right"

By marking a section of text as a div and giving it a name using id or class attributes, you are essentially creating a custom HTML element. In this example, a heading and a list are enclosed in a div identified as “sidebar.”

<div id="sidebar">        <h1>List of links</h1>
        <ul>
            <li>Resource 1</li>
            <li>Resource 2</li>
            <li>Resource 3</li>
        </ul></div>

Because a div is a block-level element, its contents will start on a new line (even text not contained within other block-level elements). Otherwise, div elements have no inherent presentation qualities of their own.

The div really shines when used in conjunction with Cascading Style Sheets. Once you’ve marked up and named a div, you can apply styles to all of its contents or treat it as a box that can be positioned on the page, for instance, to form a new text column. A div may also be called on by script, applet, or other processing by user agents.

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