Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Remove CSS line-through

Tags:

html

css

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>
like image 411
Jon Avatar asked Dec 03 '12 23:12

Jon


People also ask

How do I remove a line through text in CSS?

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.

How do you break a line in CSS?

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).

Why some CSS are strikethrough?

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.

How do you remove the underline from a tag?

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.


1 Answers

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.

like image 149
BoltClock Avatar answered Nov 15 '22 21:11

BoltClock