abcd

I woud expect" /> abcd

I woud expect" /> abcd

I woud expect"/>

CSS apply style except on :after

40 views Asked by At

From the following CSS code:

p {text-decoration: line-through;}
p:after {text-decoration: none;
content:" text";}

with HTML:

<p>abcd</p>

I woud expect the following:
abcd text

However I get this:
abcd text

Why is this and how can I get what I wanted to achieve?

2

There are 2 answers

0
Hash On BEST ANSWER

Simply add display: inline-block;

p {
  text-decoration: line-through;
}

p:after {
  content: " text";
  text-decoration: none;
  display: inline-block;
}
<p>abcd</p>

0
lock42 On

You need to select the after then apply text-decoration: none. I.e:

p:after p { text-decoration: none; }