Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I indent all text in a paragraph except the first line?

Tags:

html

css

This is an example fiddle.

What I'm trying to do is indent everything after the first line.

Right now it looks like:

Categories: Aperiri 
nostrum similique cu 
pro, maiorum delectus 
quo eu. Mentitum

I'm trying to get it to look like:

Categories: Aperiri 
  nostrum similique cu 
  pro, maiorum delectus 
  quo eu. Mentitum

I've tried adding to the css:

display: block;
margin: 2px;

But this screws up my text wrapping.

How can I have inline display but also indent after the first line in css?

like image 309
Grammin Avatar asked Jan 23 '14 18:01

Grammin


Video Answer


3 Answers

Use :first-line and text-indent tag. Put your whole text in one block (div or paragraph). Indent all lines and then set the first line to text-indent = 0

Example:

p { text-indent: -10px }
p:first-line { text-indent: 0 }
like image 134
Paul Facklam Avatar answered Nov 13 '22 09:11

Paul Facklam


You can use the text-indent property with a negative value and compensate it with a left margin.

For instance:

.negative-indent {
    margin-left: 40px;
    text-indent: -40px;
}

Reference for text-indent property: MDN

like image 41
Bruno Toffolo Avatar answered Nov 13 '22 08:11

Bruno Toffolo


How about this:

.hClass p{
    padding-left: 20px;
}


.iClass{
    font-style: oblinque;
    color: rgb(136, 136, 136);
    font-family: Arial,Liberation Sans,DejaVu Sans,sans-serif;
    margin-left: -20px;
}

See: http://jsfiddle.net/gVJK8/5/

like image 24
Sergio A. Avatar answered Nov 13 '22 08:11

Sergio A.