Preventing text-decoration from affecting the descendants is not trivial. However, since you use borders instead of text-decoration, it's even more difficult. But still possible.
If your a elements are inline (they are by default), you can use float: right:
a {
text-decoration: none;
border-bottom: 1px dotted silver;
}
a:not([href^="http://davidbraun.ch"]):after {
content: ' O';
font: 75%'PantonIcons-BRegular';
vertical-align: super;
color: #0b1b3c;
float: right;
}
Foo
<a href="http://example.com">http://stackoverflow.com</a>
Bar
But that will move the ::after too far. So you will need an inline-block wrapper:
.link {
display: inline-block;
}
a {
text-decoration: none;
border-bottom: 1px dotted silver;
}
a:not([href^="http://davidbraun.ch"]):after {
content: ' O';
font: 75%'PantonIcons-BRegular';
vertical-align: super;
color: #0b1b3c;
float: right;
}
Foo
<span class="link">
<a href="http://example.com">http://stackoverflow.com</a>
</span>
Bar
There is also the position: absolute approach:
a {
text-decoration: none;
border-bottom: 1px dotted silver;
}
a:not([href^="http://davidbraun.ch"]):after {
content: ' O';
font: 75%'PantonIcons-BRegular';
vertical-align: super;
color: #0b1b3c;
position: absolute;
}
Foo
<a href="http://example.com">http://stackoverflow.com</a>
Bar
However, now the ::after will overlap following content, so you should add some margin-right to a:
a {
text-decoration: none;
border-bottom: 1px dotted silver;
margin-right: .5em;
}
a:not([href^="http://davidbraun.ch"]):after {
content: ' O';
font: 75%'PantonIcons-BRegular';
vertical-align: super;
color: #0b1b3c;
position: absolute;
}
Foo
<a href="http://example.com">http://stackoverflow.com</a>
Bar