Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I break a long word using CSS which is browser independent?
I am using "word-break:normal/break-all/hyphenate;" css for breaking a long Sentence Which does not work on Mozila firefox or Opera.
or How to write a javascript which break a long word?
Posted

You could try the word-break in combination with word-wrap

Something like:

CSS
.MyClass
{
    word-wrap: break-word;
    word-break: hyphenate;
}


This worked in my test in IE, FF, Chrome, Opera and Safari:
HTML
<html>
<head>
    <title>wrapping test</title>
</head>
<body>
    <div style="width: 60px; word-wrap: break-word; word-break: hyphenate;">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Antidisestablishmentarianism.
    </div>
</body>
</html>
 
Share this answer
 
v2
You can include the word wrap property to break the line and display the content on next line. You have to just include this property as STYLE="word-wrap: break-word" .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900