On my website I'm using font icons for certain link types. These icons are added via :before
CSS syntax.
a.some-link:before {
font-family: icons;
display: inline-block;
padding-right: 0.3em;
content: 'x';
}
However, when this link is at the beginning of a line, it's sometimes separated from its icon:
I tried adding white-space: nowrap
to the CSS rule above but that didn't help.
How do I keep the icon and the text together? (CSS 3 is okay)
Note: I don't want to format the whole link with white-space: nowrap
.
white-space: nowrap;
doesn't work, it's because it only prevents the::before
itself from wrapping. It does does not prevent a wrap between the::before
and the subsequent element. – Heilungkiang