Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>From the <a href="http://www.w3.org/TR/xhtml1/dtds.html#dtdentry_xhtml1-strict.dtd_textarea" rel="nofollow noreferrer">DTD</a>:</p> <blockquote> <p><code>&lt;!ELEMENT TEXTAREA - - (#PCDATA) -- multi-line text field --&gt;</code></p> </blockquote> <p>In the XHTML code of your page, a <code>&lt;textarea&gt;</code> can only contain text (<code>#PCDATA</code>), and you cannot nest any XHTML elements within the <code>&lt;textarea&gt;</code>.</p> <p>Your questions seems to show two different things. The image shows "<code>&lt;br /&gt;</code>" written into a <code>&lt;textarea&gt;</code>, while the message from the W3C Validator is referring to a <code>&lt;br /&gt;</code> element written into the XHTML of your page within the <code>&lt;textarea&gt;</code> element. </p> <p>In the first case, having "<code>Test&lt;br /&gt;line break</code>" appear to the user in the text area is done by using the appropriate entities, just as <a href="https://stackoverflow.com/questions/755944/possible-to-add-line-breaks-in-a-textarea-field-while-keeping-it-xhtml-1-0-valid/755996#755996">altCognito</a> wrote:</p> <pre><code>&lt;textarea&gt;Test&amp;lt;br /&amp;gt;line break&lt;/textarea&gt; </code></pre> <p>Anything that's being entered by the user that is then redisplayed within a <code>&lt;textarea&gt;</code> on a new page should be encoded (i.e., use entities for <code>&amp;</code>, <code>"</code>, <code>'</code>, <code>&lt;</code>, and <code>&gt;</code>).</p> <p>If want to display a user's entry:</p> <blockquote> <p>Test<code>&lt;br /&gt;</code>line break</p> </blockquote> <p>...as...</p> <blockquote> <p>Test<br> line break</p> </blockquote> <p>...within another text area, then you will need to parse what has been entered into the original <code>&lt;textarea&gt;</code> and replace the user-entered <code>&lt;br /&gt;</code>s with normal line breaks. <a href="https://stackoverflow.com/questions/755944/possible-to-add-line-breaks-in-a-textarea-field-while-keeping-it-xhtml-1-0-valid/755992#755992">See Lucero's answer</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload