O'Reilly logo

Cascading Style Sheets (CSS) by Example by Steve Callihan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the DIV Element

In HTML 4, the DIV element is a block element used to designate a division within a document. Otherwise, the DIV element has no formatting characteristics, although the deprecated ALIGN attribute can be used to center or right-align its content. From the start, the DIV element was intended to take any formatting characteristics from styles.

By nesting other elements within a DIV element, any styles applied to the DIV element also impact those nested elements. In the following example, a DIV rule is added to the style sheet, set to be displayed with a border, background image, and other formatting characteristics:

 div { font-family: Verdana, Arial, sans-serif; font-size: 1.1em; color: #ffff99; background: navy url(dark.jpg); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required