I'm using the text-decoration: line-through
in CSS, but I can't seem to find any way to vary the line thickness without inelegant hacks like <hr>
or image overlays.
Is there any elegant way to specify the thickness of a line-through?
I'm using the text-decoration: line-through
in CSS, but I can't seem to find any way to vary the line thickness without inelegant hacks like <hr>
or image overlays.
Is there any elegant way to specify the thickness of a line-through?
The line thickness is determined by the font (family, size, etc.). There is no provision in CSS for changing this http://www.w3.org/TR/REC-CSS1/#text-decoration
short answer: no. it depends on the font, it's the same for the thickness of underline—it changes with the thickness of the text
Here's a pure CSS method that doesn't require any unnecessary wrapper elements. As an added bonus, not only can you adjust the thickness of the strikeout, but you can control its color separately from the text color:
Use RGBa colors to make the strikeout semi-transparent:
Or even make the strikeout a gradient! Just use a
background
combined with aheight
, in place of aborder
:This works in IE9 (sans gradient) and up – or even IE8 if you use the single-colon
:after
syntax and manually write the negativemargin-top
value instead of usingcalc()
.The main downside is that this only works on a single line of text. But hey, you take what you can get ;-)
This does not answer the question, but is relevant in that it solves the lack of a unique strike-through using scripting. I am not a purist, but I believe this is a x-browser solution.