I got a html input, and want to add a
text-decoration: line-through;
to the value (if validation fails, which sets a specific css class).
I don’t want that to appear on the placeholder though, which I tried to fix by adding a
input::placeholder {
text-decoration: none;
}
Unfortunately that doesn’t work.
Is there any way to achieve this?
>Solution :
Use :not(:placeholder-shown) to exclude the case when you have the placeholder
input.error:not(:placeholder-shown) {
text-decoration: line-through;
}
<input type="text" placeholder="example" class="error">
<input type="text" placeholder="example">