Line breaks in textarea element

后端 未结 8 1546
借酒劲吻你
借酒劲吻你 2020-12-30 22:18

This is PURE HTML. (no php or anything like that, if you want to know the background its a C# application with HTML in a web view).

All my HTML files are nicely form

相关标签:
8条回答
  • 2020-12-30 22:49

    There isn't a pure HTML solution to your problem. Textareas always display any whitespace in their contents.

    In a perfect world, you'd be able to take advantage of the CSS property white-space; unfortunately, it isn't applied to textareas either.

    0 讨论(0)
  • 2020-12-30 22:49

    Try <br/> if it is good for you:

    Monday:<br/>Tuesday:<br/>...

    0 讨论(0)
  • 2020-12-30 22:50

    If you merely want a list of items, you can use <ul> <li>"Monday"</li> <li>"Tuesday"</li> ... </ul>
    Using <ul><li></li></ul> will start a preformatted list with <ul> starting the list and <li> starting each item on the list. This method does not require any java or css and will auto indent.

    0 讨论(0)
  • 2020-12-30 22:54

    Nope; a textarea will spit back whatever it actually has.

    You could inject the value from JavaScript, but that seems like a lot of work for an isolated thing.

    0 讨论(0)
  • 2020-12-30 23:01

    This works for me in angular:

    ts: log: string[] = [];

    html: <textarea row=5 col=50>{{ log.join("&#10;") }}</textarea>

    result: in textarea each item of log is shown in a new line.

    0 讨论(0)
  • 2020-12-30 23:02

    You could use the &#10; (it means new line in html) but maybe that's not a nice formatting, like you said...

    The only way I can think to remove this issue is to remove the indentation. Its not the end of the world, but is there another way, to keep the nice formatting?

    <tr>
      <td class="label">Clinic Times:</td>
      <td><textarea name="familyPlanningClinicSessionsClinicTimes">Monday:&#10;Tuesday:&#10;Wednesday:&#10;Thursday:&#10;Friday:&#10;Saturday:&#10;Sunday:</textarea></td>
    </tr>
    
    0 讨论(0)
提交回复
热议问题