Producing web pages
* HTML CSS DHTML XHTML A to Z of tags        Accessibility          Design

text-indent

The text-indent indents the first line of a paragraph. You can't really do this in standard HTML; you have to add non-breaking spaces or a blank picture to the first line of every paragraph.

You can specify indentation in millimetres, centimetres, inches, points, picas, pixels, the height of the font (em), the height of the letter x (ex) or as a percentage. For example:

p {text-indent: 0.5in;}

This makes the browser indent your paragraphs 0.5" from the left margin.

You might want to set the indent as a percentage so that the indent is relative to the width of the text or use em to set the indent relative to the font size. If you use ems, the indent scales as the font gets bigger or smaller.

You can also use negative values to pull the text out into the margins. This creates a hanging indent. To do this, you need to use the text-indent property and the margin-left property. For example:

p {text-indent : -3em; margin-left : 3em;}

This property works on block tags.