I have ghost text in textfields that disappear when you focus on them using HTML5's placeholder attribute:
<input type="text" name="email" placeholder="Enter email"/>
I want to use that same mechanism to have multiline placeholder text in a textarea, maybe something like this:
<textarea name="story" placeholder="Enter story\n next line\n more"></textarea>
But those \n
s show up in the text and don't cause newlines... Is there a way to have a multiline placeholder?
UPDATE: The only way I got this to work was utilizing the jQuery Watermark plugin, which accepts HTML in the placeholder text:
$('.textarea_class').watermark('Enter story<br/> * newline', {fallback: false});
white-space
to make sure it's set correctly e.g. pre-wrap – Romeoromeon
works everywhere except Safari. – Mawkish\n
between lines, or a native es6 string inwith multiple lines delimited this way
, and you also need to style the textarea element withwhite-space: pre;
. – Stationmaster