Reputation:
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 and you want the text on the button to be on 2 lines for example..
Thanks in advance !
Upvotes: 6
Views: 14848
Reputation: 71
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
Upvotes: 0
Reputation: 5558
This worked for me (using Chrome, didn't test other browsers):
myButton.Text = "Click \r\n me";
Upvotes: 0
Reputation: 15946
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.
Upvotes: 2