user3723041
user3723041

Reputation: 81

How to add multi line place holder text in textarea?

How to add multi line place holder text in textarea? .

I got a solution like following but its not working im mossilla, safari.

Chrome works this way..

$('#nameTxtBox').attr("placeholder", "League Name \n 1-2 lines most designs");

Upvotes: 1

Views: 3235

Answers (2)

Merrin K
Merrin K

Reputation: 1790

Try This code

just add "&#10" before the new line without space.

<textarea  placeholder='First Line &#10;Second Line &#10;Third Line' rows="5"></textarea>

Upvotes: 2

Bryant Makes Programs
Bryant Makes Programs

Reputation: 1704

Unfortunately multi-line placeholders are not supported as a rule. Chrome does allow for newline characters, but support across platforms can be spotty. The recommended course of action would be to create shorter, single-line placeholders. If you absolutely need a multi-line placeholder, you can try this:

<textarea style='white-space:pre;' placeholder='Line 1

Line2'></textarea>

By adding the css attribute white-space:pre, you force the textarea to treat the placeholder text as preformatted text. Again, though, support is spotty.

Upvotes: 1

Related Questions