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

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.