문제

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.

도움이 되었습니까?

해결책 2

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>

다른 팁

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top