12

I have an HTML textarea with a "placeholder" attribute that includes the code for a line break, &\#10;. It works fine on Chrome, but the line break is ignored on other browsers. What is causing this inconsistency, and how do I work around it?

4
  • 1
    Take a look at this page <a>stackoverflow.com/questions/33909888/…> Commented Dec 24, 2017 at 4:49
  • I can't include a <br> tag in an HTML attribute. Commented Dec 24, 2017 at 5:26
  • Instead of the line break thing, use \n as new line in your placeholder. it's definite to work across browsers. Commented Dec 24, 2017 at 6:00
  • That just displays a literal "\n". Commented Dec 24, 2017 at 6:10

1 Answer 1

7

Include the line break naturally with the keyboard enter? Like it is shown in this image, click to see it.

If it does not work, try inserting your place holder text via javascript?
See Insert line break inside placeholder attribute of a textarea?

Sign up to request clarification or add additional context in comments.

2 Comments

A literal line break only seems to work in the same browsers as &\#10;- In Firefox and Safari, it's just ignored. The other answer you linked to mentioned that the spec forbids line break characters in the placeholder text, so I guess it's Chrome that's non-compliant. That's quite frustrating. That other thread included some workarounds through, so I can use one of those.
yup. guess it has to be worked around. until the major browsers arrived in the future to support the same standards.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.