如何摆脱文本区域中的多余空间?

问题描述:

我正在生成一个HTML表单,该表单在文本区域中包含一些代码.

I am generating an HTML form, which contains some code in a text area.

生成的HTML如下所示:

The generated HTML looks like this:

<textarea id="message" name="message"
    rows="18" cols="40">The quick brown fox
    <?php echo $page_url;?>
</textarea>

在浏览器中呈现页面时,它看起来像这样:

When the page is rendered in a browser, it looks like this:

The quick brown fox
         http://www.example.com

我无法解释它,因为该变量不包含任何前导空格-也不应用CSS样式.

I cant explain it, since the variable contains no leading spaces - and no CSS styling is being applied either.

有人能想到这是什么原因吗?

can anyone think of what may be causing this?

< textarea> 内的空格按原样呈现,而不像HTML那样将连续的空格呈现为一个.

Whitespaces inside <textarea> are rendered as-is, unlike HTML, which renders successive whitespace as one.

<textarea id="message" name="message"
    rows="18" cols="40">The quick brown fox<?php echo $page_url;?></textarea>