Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Line-Through not being removed

Tags:

html

css

I've got some code that puts a line-through on a TR for deleted rows, but this means that my "Actions" column (that only has) buttons suffers. This is because there are individual spaces between the buttons, which wind up getting line-throughed as well.

After poking around on W3Schools, it boggles me why this example doesn't work:

<html>
  <head>
  <style type="text/css">

    tr {text-decoration:line-through}
  </style>
  </head>

  <body>
    <table>
      <tr>
        <td>this needs to be line-throughed</td>
        <td style="text-decoration: none !important;">This shouldn't be line-throughed.</td>
      </tr>
    </table>
  </body>
</html>

How am I supposed to clear the line-through on child elements?

EDIT I've updated my example - the problem is that I do not want to take the style off the parent element, just a single child element.

like image 794
JustLoren Avatar asked Nov 18 '09 19:11

JustLoren


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.

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

How do you put a line through text in CSS?

The property text-decoration-line is used to underline the text. This property has three values that are overline, underline, or line-through. So, the value underline is used to underline the text in CSS. This value draws the underline beneath the inline text.


2 Answers

You shouldn't have to use important or inline styles for this. Try

h2 {text-decoration:line-through;}
h2 span {text-decoration: none; border: 1px solid black;}

EDIT

In that case with tr since yeah you applied text-decoration to it, you have to take text-decoration off the same element tr not td. Otherwise do:

tr td { text-decoration: whatever }

and then when needed

<td style="text-decoration: none;"></td>
like image 157
Dmitri Farkov Avatar answered Sep 30 '22 13:09

Dmitri Farkov


There was a similar question a little while back and according to that answer you can't do what you're trying to accomplish.

EDIT: Given your example, why not just apply the line-through to TD elements individually

<html>
  <head>
  <style type="text/css">

    td.deleted {text-decoration:line-through}
  </style>
  </head>

  <body>
    <table>
      <tr>
        <td class="deleted">this needs to be line-throughed</td>
        <td>This shouldn't be line-throughed.</td>
      </tr>
    </table>
  </body>
</html>
like image 38
Marek Karbarz Avatar answered Sep 30 '22 12:09

Marek Karbarz