I have a sidebar with a list of links and each link has an arrow icon to the right of it (set in the anchor styles using the :after selector). On many of the links, the arrow is dropping down to its own line. I want to make sure the text can break to a new line as needed, but prevent the arrow from being orphaned onto a line by itself.
I thought I had solved the problem by using "white-space: nowrap" on the :after pseudo element because that worked in Firefox. Unfortunately, I discovered it isn't working in IE8, Chrome & Safari.
Is there a way to prevent the link icon from breaking to its own line, while still allowing the text in the link to wrap as needed, in Firefox, IE8, Chrome and Safari?
Basic HTML structure:
<div id="sidebar">
<ul>
<li><a>Link 1</a></li>
<li><a>Link 12</a></li>
</ul>
</div>
The style rules (written in sass):
div#sidebar
width: 170px
a:after
content: url('images/icon_double-arrow.png')
margin: 0 0 0 6px
white-space: nowrap
I believe I resolved the issue. I changed the styles so that the arrow image is set as the anchor background and positioned it to the right using padding instead of setting the arrow image as :after content. Works in all mentioned browsers: a border: 0 background: url('images/icon_arrow.png') no-repeat right center padding-right: 15px