How to have an Input submit value on several lines in HTML

后端 未结 4 434
春和景丽
春和景丽 2021-02-04 18:52

Does anybody know if there is a way to display the text value of an button in HTML on several lines ?

I mean, if you lock the width of the button in the associated CSS

相关标签:
4条回答
  • 2021-02-04 19:14

    Split the text on the button by adding where you want to break the line the following sequence: \r\n For example: <input type="submit" value="Line1\r\nLine2"> will display a submit button with caption Line1 on top of the Line2.

    For beginners: \r\n will not be displayed, but used by the browser to understand that you want to break the line; it is not necessary to leave empty spaces on the left or the right of \r\n

    0 讨论(0)
  • 2021-02-04 19:24

    You can use the <button> element, which allows for styling (and text-wrapping).

    Only problem with that is that if you have multiple button elements on the same page, you will potentially run into issues with IE6 passing name/value pairs to the server incorrectly.

    0 讨论(0)
  • 2021-02-04 19:31

    This worked for me (using Chrome, didn't test other browsers):

    myButton.Text = "Click \r\n me";
    
    0 讨论(0)
  • 2021-02-04 19:38
    <input type="button" value="line &#10; break" />
    
    0 讨论(0)
提交回复
热议问题