How to wrap text of HTML button with fixed width?

Peter picture Peter · May 14, 2009 · Viewed 234k times · Source

I just noticed that if you give an HTML button a fixed width, the text inside the button is never wrapped. I've tried it with word-wrap, but that cuts of the word even though there are spaces available to wrap on.

How can I make the text of an HTML button with a fixed width wrap like any tablecell would?

The CSS classes do nothing but adding borders and modify the padding. If I add word-wrap:break-word to this button, it will wrap it like this:

Roos Sturingen / Sen
sors

And I don't want it to cut of in the middle of a word if it is possible to cut it off between words.

Answer

Siu picture Siu · Jul 28, 2009

I found that you can make use of the white-space CSS property:

white-space: normal;

And it will break the words as normal text.