Reuben Reuben - 5 months ago 12
CSS Question

Indenting the 2nd line of a paragraph with CSS

I'm curious how everyone would go about indenting the 2nd line of a paragraph.

I've tried

p{text-indent: 200px;}
p:first-line{text-indent: 0;}


and

p{margin-left: 200px;}
p:first-line{margin-left: 0;}


and

(with position:relative;)
p{left: 200px;}
p:first-line{left: 0;}


Any ideas?

Thanks!

Answer

Is it literally just the second line you want to indent, or is it from the second line (ie. a hanging indent)?

If it is the latter, something along the lines of this JSFiddle would be appropriate.

HTML

<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</div>
<br/><br/>
<span>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</span>

CSS

div {
    padding-left: 1.5em;
    text-indent:-1.5em;
}

span {
    padding-left: 1.5em;
    text-indent:-1.5em;
}

This example shows how using the same CSS syntax in a DIV or SPAN produce different effects.