4

I don't want to use just a {text-decoration:none;} as I don't want to affect all links

I have a div with class="explore" that has no content except :after which generates the content using css:

    content: "Explore";
    vertical-align: top;
    text-decoration: none;

I have then wrapped the div with <a href="#">...</a>

This give the text "example" an underline which I can't seem to remove; I've tried:

.explore a { text-decoration:none; }

.explore:after a { text-decoration:none; }

a .explore { text-decoration:none; }

a .explore:after { text-decoration:none; }

None of which seem to affect the text at all.

How can I remove the underline?

FIDDLE

SaturnsEye
  • 5,937
  • 9
  • 44
  • 59

4 Answers4

30

If you'll set display: inline-block to ::after block, underline will disappear.

mortiy
  • 629
  • 7
  • 9
1

Simply apply text-decoration for the link:

a{text-decoration:none;}

demo

Bhojendra Rauniyar
  • 78,842
  • 31
  • 152
  • 211
1

My first question why do you want to use a block element inside an inline element which looks odd. Secondly you can make your markup just simple as below. Though you want to add block elements just add display:block; to your <a>

<a class="explore" href="#">explore</a>

STYLE

.explore{
    text-decoration: none;
    display: block;
}

DEMO

Benjamin
  • 2,522
  • 2
  • 17
  • 31
-1

You have to write one thing only a{ text-decoration:none; }

user3074446
  • 132
  • 10