Is there anything in HTML like heredoc syntax in PHP? Because in case of a span with long text I have to use br tags each time I want to have a linebreak.
Asked
Active
Viewed 575 times
0
2 Answers
2
Don't use spans with long text, use paragraphs, or parse your text as if it were Markdown, like here:
Some Line
Some Other Line
will render to:
<p>Some Line</p>
<p>Some Other Line</p>

moonwave99
- 21,957
- 3
- 43
- 64
1
The <pre>
tag sounds like what you're looking for. From MDN: Whitespaces inside this element are displayed as typed.
<pre>
Hello
!!!
World
</pre>
becomes
Hello
!!!
World
You can also use the white-space
CSS property to achieve a similar effect on any tag, though it behaves slightly differently.
<span style="white-space:pre;">Hello
!!!
World
</span>

terite
- 121
- 3
` elements, and allow the browser to wrap the text inside some containing element. Or is that too easy?
– Jul 11 '13 at 14:45