CSS word-wrap: break-word don't work on IE9
Asked Answered
T

9

28

I have a small css script that force <a> tag word-wrap in a div. It worked fine on FF, Chrome but didn't work on IE9. How can I fix it?

.tab_title a{
    word-wrap: break-word;
} 
Toneme answered 6/12, 2011 at 2:34 Comment(1)
The solution in this post worked for me: https://mcmap.net/q/338566/-word-wrap-break-word-not-working-in-ie8Ulceration
T
4

I remove the anchor tag after .tab_title class and it works

Toneme answered 6/12, 2011 at 2:59 Comment(1)
.tab_title{ word-wrap: break-word; } .tab_title a{ word-break: break-word; }Alerion
R
29

For a similar issue, I used display: inline-block on the <a> tag, which seems to help. And word-break: break-all as I was concerned with long URLs not wrapping.

So, this in your case essentially...

.tab_title a {
    display: inline-block;
    word-break: break-all;
} 
Rubberneck answered 8/6, 2015 at 9:38 Comment(0)
S
17

For me it worked in both Chrome and IE with:

.word-hyphen-break {
  word-break: break-word;
  word-wrap: break-word;
  width: 100%;
}

like this no need to configure specific width.

Suffragan answered 11/8, 2018 at 20:43 Comment(0)
K
13

This might do the trick: http://www.last-child.com/word-wrapping-for-internet-explorer/

Another post also suggests applying word-break:break-all and word-wrap:break-word to it.

Knur answered 6/12, 2011 at 2:39 Comment(1)
like this link suggested "word-break: break-all" does the job! Thanks.Jinn
F
8

Try this:

.tab_title a{
    -ms-word-break: break-all;
    word-break: break-all;
    word-break: break-word;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    hyphens: auto;
} 
Francie answered 31/7, 2015 at 13:54 Comment(1)
That approach does not work with display flex, I changed the element to display block and worked just fine.Googol
T
4

I remove the anchor tag after .tab_title class and it works

Toneme answered 6/12, 2011 at 2:59 Comment(1)
.tab_title{ word-wrap: break-word; } .tab_title a{ word-break: break-word; }Alerion
V
3

word-wrap: word-break; works only in ff and chrome and not in IE8 and IE9.
word-break: break-all; does not work either.

Velazquez answered 7/3, 2013 at 16:21 Comment(0)
S
3

I have had good success in Chrome, Firefox and IE with using:

word-break: break-word;
word-wrap: break-word;

In my problem case I was using:

display: table-cell;

and I ended up having to include

max-width: 440px;

to get wrapping in all browsers. In most cases the max-width was not necessary. Using

word-break: break-all;

does not work well in IE because although long words without spaces will be wrapped, short words also stop wrapping at spaces.

Selfgratification answered 28/4, 2017 at 18:34 Comment(2)
fyi, I also had the same issue with IE11. I got it to wrap big words in my table, but it seems to wrap tiny words as well, when it could have easily put it into a separate line. I'm glad I'm not the only one. Did using max-width fix it for you? I just tried it on my TD, but no luck.Remise
Yes, in most cases: word-break: break-word; word-wrap: break-word; worked, but in the one case that it didn't, also specifying max-width did the trick.Selfgratification
B
0

I recently was fighting this in Angular between IE/Edge & Chrome. Here is what I found worked for me

  overflow-wrap: break-word;
  word-wrap: break-word;

This gave me the best of both. It would break the word that was too long, but unlike word-break it would not break mid-word.

Blink answered 1/6, 2017 at 14:40 Comment(0)
V
-1

i just figured out that word-wrap:break-word works only partially in IE8 and IE9. If I have a string of words with spaces, then that string gets wrapped. But if my string consists of one long word, it forces the parent/container element to expand according to its width

Velazquez answered 7/3, 2013 at 23:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.