0

I have a div tag that displays plain text. Depending on the width of the text or the div, the text may be displayed on one line or multiple lines.

Task:

How to indent the first line only when there are 2 or more lines?

1 Answers1

0

The text-indent property specifies the indentation of the first line in a text-block.

div p {
  text-indent: 2em;
}

If you want to apply this to the first paragraph only in the div you can use :first-child Selector

div p:first-child {
  text-indent: 2em;
}