Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override “text-decoration: line-through” for “:before/:after” pseudo class

Tags:

html

css

Do you know why the line-through text-decoration for :before isn’t being overridden?

Demo: http://jsfiddle.net/FZJYW/

HTML

<p>Should be strike-through</p>

CSS

p {
  text-decoration: line-through;
}

p:before {
  content: "Should not be strike-through. ";
  text-decoration: none !important;
}

Any ideas how to make only part of text line-through without adding an extra element, like <span>?

like image 884
Alex Avatar asked Jun 18 '14 20:06

Alex


People also ask

How do you put a line-through text in HTML?

The <strike> HTML element places a strikethrough (horizontal line) over text. Warning: This element is deprecated in HTML 4 and XHTML 1, and obsoleted in HTML5. If semantically appropriate, i.e., if it represents deleted content, use <del> instead. In all other cases use <s> .

Which text-decoration property displays the line above the text?

overline: It is used to display a line over the text.


1 Answers

Add display: inline-block to the pseudo element's css properties

like image 105
Gray Spectrum Avatar answered Nov 15 '22 07:11

Gray Spectrum