Question

I have the following style already: white-space: pre-wrap;

This allows newlines to be treated as newlines (and spaces don't get collapsed) for the element.

Now I want to apply text-indent: -40px; padding-left: 40px; in an attempt to produce something like this:

This is a long line of text (or at least, just pretend it is) so it  
        will indent when it wraps.
Further lines of text appear as normal, but again if they exceed the
        maximum width then they wrap and indent.

Unfortunately, it's not doing quite what I intended:

This is a long line of text (or at least, just pretend it is) so it
        will indent when it wraps.
        Further lines of text appear as normal, but again if they
        exceed the maximum width then they wrap and indent.

Is there a way in CSS to indent wrapped lines, but counting newlines as a new first line?

Was it helpful?

Solution

No, because text-indent relates to the first line of an element, and newlines generated by line wrapping do not create elements. So instead of just newlines in HTML source, you need to use some content markup.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top