Jump to content

How to text-indent with carriage returns


Recommended Posts

I have a string that I run through nlbr2(), nlbr() works fine but when I apply the css property text-indent it only indents the first line of text.

So it looks like

 

    xxxxxxxxxxx

xxxxxxxxxxxxxx (carriage return)

xxxxxxxxxxxxxx

xxxxxxxxxxxxxx

 

And I want the text to look like this

 

    xxxxxxxxxxx

xxxxxxxxxxxxxx (carriage return)

    xxxxxxxxxxx

xxxxxxxxxxxxxx

 

 

How do you text-indent with carriage returns ?

 

Thanks in advance

S

 

 

 

You use a margin or padding... text indent is supposed to do exactly what you're saying (indent the first line of the text like proper paragraph formatting calls for).

 

In order to achieve what you're looking for, I would think you just need to split them into multiple paragraphs.

I guess I shouldn't have used the word paragraph, I pondered what to call it for a few seconds before I posted the post.

 

Is there anyway to indent the lines I'm talking about, if I can't indent them then I would expect that I couldn't  put a space between them either.

 

The way the (artical(?), text) looks now is all jumbled up.

 

So can I indent them someway or is there a way I can put each string of text ending in a carriage return in html paragraph tags?

 

 

Thanks again

Just make them actual paragraphs and use text-indent. If you're concerned about all of whatever you already have stored in a database table, you can echo an opening '<p> tag, str_replace() the linefeeds with '</p><p>', then echo the closing '</p>' tag.

 

echo '<p class="whatever">';
echo str_replace("\n", "</p>\n<p class=\"whatever\">", $your_text);
echo '</p>';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.