demosthenes.info

I’m Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with , and . To receive more information, including news, updates, and tips, you should follow me on Twitter or add me on Google+.

web developer guide

my books

Book cover of Pro CSS3 AnimationPro CSS3 Animation, Apress, 2013

my projects

A Sass color keyword system for designers. Replaces CSS defaults with improved hues and more memorable, relevant color names.

CSSslidy: an auto-generated #RWD image slider. 3.8K of JS, no JQuery. Drop in images, add a line of CSS. Done.

tipster.ioAutomatically provides local tipping customs and percentages for services anywhere.

Introduction to divs

html / elements

Estimated reading time: 1 minute, 6 seconds

There are several elements that I have not introduced to this point because without they have little point, and almost no meaning. These elements include span and div.

div is arguably the most overused and misunderstood element in the HTML specification, so let’s try to kill a few common mistakes right off the bat:

In CSS, anything you can do to a div you can do to any other tag

div is not special in that regard. You do not need to use a div in order to access advanced CSS such as .

A div should almost never contain a single element

Because anything you can do to a div you can do to any other element, wrapping a div around a single element is almost always redundant and unnecessary.

A div is not a substitute for, or addition to, a block element

An unordered list, for example, already has a container element: <ul>. Wrapping a <div> around the <ul> is redundant.

A div is not necessary to add an extra border to an element

Use the outline property or box-shadow to achieve the effect instead.

Avoid setting height on div elements (in fact, avoid setting a height on all elements other than images).

Other than uses of height: 100%, allow div elements to find their own height, determined by their content.

comments powered by Disqus

This site helps millions of visitors while remaining ad-free. For less than the price of a cup of coffee, you can help pay for bandwidth and server costs while encouraging further articles.