I have a table with cells of variable width, and I want to give the browser the ability to insert a line break before the slash, without forcing it. I tried this by inserting a zero-width character (ZWSP) in front of the slash, and it works fine in all browsers I tested it except for IE6 and IE8.
For IE6, I use some Javascript to replace the character with the <wbr> tag - not the most elegant solution, but it works.
In IE8, I did not find a practical way to get around it. This will ruin the layout of my table. I found out that this is not limited to tables only. This seems to be happening with any element. The browser refuses to recognize the ZWSP, choosing instead a text coming out of the box that looks ugly. I noticed that I can get the browser to handle it properly by putting it in the compatibility view, but this causes other problems for me.
Does anyone know a simple and practical way to make ZWSP behave as it is supposed to in IE8?
You can use this code to verify the problem:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><head> <title>zwsp test</title> </head> <body> <div style="width: 50px; border: solid black 1px; font-size: 15px"> Miles​/gallon </div> </body></html>
html internet-explorer-8
Elias zamaria
source share