How to indent starting from the second line of a paragraph with CSS?

Spread the love

Sometimes, we want to indent starting from the second line of a paragraph with CSS.

In this article, we’ll look at how to indent starting from the second line of a paragraph with CSS.

How to indent starting from the second line of a paragraph with CSS?

To indent starting from the second line of a paragraph with CSS, we use the text-indent property.

For insrance, we write

<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>

<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>

to add some text.

Then we write

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

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

to set the text-indent position and padding-left to move indent the text startingh from the 2nd linee.

Conclusion

To indent starting from the second line of a paragraph with CSS, we use the text-indent property.

Leave a Reply

Your email address will not be published. Required fields are marked *