I am trying to remove the text-decoration:line-through;
style applied to my element and I cannot seem to be able to do so. I have tried text-decoration:none;
but it does not work.
When I apply text-decoration:underline;
to span
, it seems that instead of replacing the line-through
style the browser adds the underline
style.
I know I can always re-write my HTML so the elements that require a line-through
has their own class. I'm wondering if there is an alternative other then restructuring my HTML.
http://jsfiddle.net/wshHW/
<style>
p { text-decoration:line-through; }
span { text-decoration:none; }
</style>
<p>Foo <span>bar</span></p>
If you want to remove the CSS strikethrough from your text, you can use the none value for the text-decoration property. This will remove any strikethrough from your text.
A line-break can be added in HTML, using only CSS, by employing the pseudo-class ::after or ::before . In the stylesheet, we use these pseudo-classes, with the HTML class or id, before or after the place where we want to insert a line-break. In myClass::after : Set the content property to "\a" (the new-line character).
If you can see your new CSS in the Styles pane, but your new CSS is crossed out, it means that there's some other CSS that is overriding your new CSS. In CSS terminology this concept is called Specificity. Chrome DevTools can help you find the old CSS that is causing your new CSS to not be applied.
Complete HTML/CSS Course 2022 To remove underline from a link in HTML, use the CSS property text-decoration. Use it with the style attribute. The style attribute specifies an inline style for an element. Use the style attribute with the CSS property text-decoration to remove underline from a link in HTML.
I know I can always re-write my HTML so the elements that require a
line-through
has their own class. I'm wondering if there is an alternative other then restructuring my HTML.
Not really. The behavior you see is totally by design; ancestors will always propagate their text decorations to certain descendants, and conversely you can't affect an ancestor's text decoration from within a descendant.
There isn't a very viable alternative to restructuring, currently, although text-decoration-skip
from the upcoming CSS3 text decoration module looks promising.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With