Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to break long single word in <td> using CSS?

Tags:

html

css

xhtml

in a td of a table i have a very long single word "Pneumonoultramicroscopicsilicovolcanoconiosis" and i want to reduce the width of table but unable to do because of this long word in one of the td i can break this word by giving <br /> but is there any CSS way to break this word according to available space. without giving line break or edit anything in HTML.

like image 955
Jitendra Vyas Avatar asked Jul 28 '10 04:07

Jitendra Vyas


People also ask

How do you break a single long word in CSS?

The word-break property in CSS is used to specify how a word should be broken or split when reaching the end of a line. The word-wrap property is used to split/break long words and wrap them into the next line. word-break: break-all; It is used to break the words at any character to prevent overflow.

How do you break a long text in CSS?

The <wbr> element If you know where you want a long string to break, then it is also possible to insert the HTML <wbr> element. This can be useful in cases such as displaying a long URL on a page.

How do you break a long word in HTML?

Use word-wrap:break-word; It even works in IE6, which is a pleasant surprise. word-wrap: break-word has been replaced with overflow-wrap: break-word; which works in every modern browser.


2 Answers

Try the following:

word-wrap: break-word; white-space: normal; 

word-wrap is css3 (however it works in IE). You might not be able to get it working in older browsers however.

like image 168
Ben Rowe Avatar answered Sep 17 '22 21:09

Ben Rowe


The following works for me:

    word-wrap: break-word;     word-break: break-all;     white-space: normal; 
like image 39
Tigertron Avatar answered Sep 17 '22 21:09

Tigertron