Roni Axelrad
Roni Axelrad

Reputation: 439

Have a break line in HTML element value

I want to have a break in a button value on chrome, which used to work fine till their last update 3 weeks ago, since then, that stopped working:

<input type="button" value="line &#10; break" />

JSFiddle :

No line break

Does anyone have any new ideas to get this line break in an element value ??

Upvotes: 2

Views: 3359

Answers (3)

Rguarascia
Rguarascia

Reputation: 193

Instead of using

<input type="button" />

You should use the button tag instead, which in turn you can use the HTML <br/> tag to make your line break. This should work on all browsers as this is a valid HTML code.

<button>
   Line<br/> 
   Break
</button>

Upvotes: 0

zer00ne
zer00ne

Reputation: 43880

input[type="button"] {
  white-space: normal;
  text-align: left;
  width: 6ch;
}
<input type="button" value="line break" />

You can use "white-space: normal" if you don't want to use <button> The width of the button could be set to the length of your longest word by the unit measurement ch one ch = width of one letter.

Upvotes: 2

rvillar
rvillar

Reputation: 76

How about?

<button>
<span>Line 1</span><br/>
<span>Line 2</span>
</button>

Upvotes: 2

Related Questions