Markup - soft line break

I may be able to find the answer to this question by poring over the spec, but someone probably knows offhand: How does one create a manual line-break (soft CR) in an <input> element's text Assuming that the text value is being set during runtime, it stands to reason that one of the old standards (<br> tag, chr(13)+chr(10), etc.) ought to work. Is there a Unicode linebreak character and if so is there an entity code for it


Answer this question

Markup - soft line break

  • nmxnmx

    Assuming you are using an input with mode=multiline, the linebreak characters are either:

    Line separator: U+2028

    Paragraph separator: U+2029

    This can be found in a whole section on line breaking in chapter 7: 7.3.2.3.

    Script to set these values would look like the following, assuming the existence of an input element with id="text":

    document.text.state.value = "line1" + String.fromCharCode(0x2028) + "line2" + String.fromCharCode(0x2029) + "line3";

    The strings line1, line2, and line3 will appear on 3 different lines in the input. A better practice would be to store the linebreak chars away as constants instead of using fromCharCode each time, but you get the idea



  • Markup - soft line break