rkb
rkb

Reputation: 544

How can I add line break to html text without using any html tag

I want to insert a line break into my profile text on a website, which only allows text to be inserted, so I can not use any html tag.

I would like to know if there in any way to insert line break just like inserting spaces or tabs using ASCII codes?

Upvotes: 5

Views: 24818

Answers (8)

8r4a5n7d2o7m4
8r4a5n7d2o7m4

Reputation: 91

In mailto body, this created a new line without any issues: %0D

Upvotes: 0

Steven Peirce
Steven Peirce

Reputation: 546

You can set the white-space to pre-line - this will then respect carriage returns.

p {
    white-space: pre-line;
}
<p>Hello,\r\nGoodbye!</p>

Will render:

Hello,
Goodbye!

Upvotes: 9

Shiran Dror
Shiran Dror

Reputation: 1480

You can use the <pre> tag when sending the email. Inside this tag textual line breaks are shown as actual line breaks in html.

<p>
  this is a 
  text with 
  line breaks
</p>
<pre>
this is a 
text with
line breaks
</pre>

Upvotes: 2

Deo
Deo

Reputation: 82

Try \n just after from where you want to break the line.

Upvotes: -1

J-T
J-T

Reputation: 9

You and anyone else reading this can use this probably

%0A

Upvotes: -3

Weaver
Weaver

Reputation: 628

You probably can't add an arbitrary line break. However, you can influence where a line break occurs if the text is to be rendered inside a container that is not long enough to display the text as a single line. Just use non-breaking spaces at the right places in the text.

Let's suppose the text contains sentences and it is going to be broken to several lines and you want a line break to occur before a certain sentence. Then use non-breaking spaces instead of regular spaces in the sentence. The specific sentence will then possibly not fit on the current line and will be rendered on a new line:

The text is to be rendered in this box. Let's force a line break now.
This•text•starts•on•a•new•line as it will not fit on the previous line without breaking the text
(• stands for &nbsp;).

Upvotes: 1

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201568

There isn’t. You can enter e.g. a LINE FEED character as &#10;, but it won’t help: by HTML rules, it will still be taken just as yet another whitespace character, and any sequence of whitespace characters is equivalent to one SPACE in normal HTML content. You cannot override the HTML rules for processing characters by the characters themselves (only by HTML markup or by CSS).

Upvotes: 5

aNGRoN
aNGRoN

Reputation: 83

I think you are looking for codes like '&nbsp;' and so...
The 'carry return' code is '&#13;'

Maybe what you are looking for is in there: ASCII HTML CODES

Upvotes: 6

Related Questions