Skip to Main Content
Painting the Web
book

Painting the Web

by Shelley Powers
May 2008
Beginner content levelBeginner
656 pages
17h 41m
English
O'Reilly Media, Inc.
Content preview from Painting the Web

div Play Dough

We don't want to add to page complexity by dumping a bunch of div or other elements into the page design. At the same time, though, we don't want to shortchange ourselves by not trying out some new web design tricks just because they add more divs to an existing stack of page elements.

Ten years ago, I wrote, "The div element is the play dough of the Web." You can use it to group, contain, position, and frame. It has no semantics, so using it anywhere won't affect the meaning of the page. It has no accessibility constraints, so its use won't impact adversely on screen readers.

Using the background image column trick

Figure 8-7. Using the background image column trick

The div is not a replacement for other HTML elements. For instance, it's not a header element, and shouldn't be used in place of any of the hi–h6 header elements. It's also not a list item, and shouldn't be used in place of ul/li or ol/li. Nor is it a quote (blockquote), citation, address, abbreviation, and so on, to be used in place of these other, more meaningful page elements.

The div is a way to define a section of the web page: nothing more, nothing less. However, for all the places where it shouldn't be used, it's the most important page element and, frankly, we'd still be back with layout-by-tables if it weren't for the div element.

Aside from its layout capability, there are other uses for the div element. Earlier in this book, I covered how ...

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

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
Mastering PHP 7

Mastering PHP 7

Branko Ajzele

Publisher Resources

ISBN: 9780596515096Supplemental ContentErrata Page