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

my books

Pro CSS3 Animation book coverPro CSS3 Animation, Apress, 2013

my other blogs

Massive Head CanonMassive Head Canon: Intelligent discussion of movies, books, games, and technology.

my projects

The New DefaultsThe New Defaults — A Sass color keyword system for designers.

CSSslidyCSSslidy — an auto-generated #RWD image slider. 3.8K of JS, no JQuery.

Classic Typography Effects in CSS: Hanging Indent

How to create the classic typographic effect of a hanging indent in CSS.

A hanging indent, or hanging paragraph, is a paragraph in which the opening line is left of the margin. In other words, the first line has a negative text indent, and that is exactly how it is created in CSS. First, our HTML markup:

Then the CSS code, written embedded or linked:

Our immediate problem is that this style would apply itself to every paragraph. We need to restrict the effective range of the style to the first paragraph. So long as we’re ignoring IE6 (which would require a referenced id on the paragraph to work similarly) and are consistent in our markup, the easiest way is with an adjacent selector:

This creates a problem of its own: the first line of our first paragraph is now likely to go off the left edge of the browser window. To compensate, push the paragraph to the right with margin-left:

We probably want all the paragraphs to share the same left edge, so rather than applying the margin-left to just the first paragraph after the h3, apply it to all paragraphs. Typically, we would also balance the margin on the right-hand side and justify all paragraphs:

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.