0

My link should look like this:

> My link text
  ____________

while "My link text" should be underlined and the content in the ::before part should not be.

I tried it like this:

a {
   text-decoration: underline;
}

a::before {
   content: ">";
   text-decoration: none;
}

But no success. It's always underlined. What can I do?

EDIT: One answer was, that I should simply add display: inline-block to the ::before part. BUT the problem I am getting with this is, that the links breaks somethimes after the icon. I definitly need to avoid that. And the solution I have found for that is to REMOVE the display: inline-block. So, for the one or the other I need another solution. display: inline-block is not the right one.

JonSnow
  • 573
  • 14
  • 48

1 Answers1

0

Setting display: inline-block on the pseudo element (::before) will allow it to not inherit the text-decoration.

See https://codepen.io/RonnyO/pen/vYGvNWp?editors=1100

Already explained in detail elsewhere.

Ronny
  • 4,295
  • 2
  • 24
  • 30