XHTML and CSS strike alternatives
Example of XHTML syntax equivalent to HTML strike attribute, for websites that conform with the W3C standards.
It's often needed to cross out a text or a word, to delete it without necessarily having to remove it from the page.
HTML makes this through the tag <s> and <strike>, but they have been deprecated in HTML 4.01 and they are not supported in DTD XHTML 1.0 Strict.
To get the effect of the crossed out text, while remaining compatible with the standard W3C, you can choose between two solutions: the <del> tag and the use of CSS.
HTML <del> tag
The <del> tag is the XHTML equivalent of the <strike> tag (now deprecated) and, as it serves to defines text that has been deleted in a document.
Use it together with the <ins> tag to describe updates and modifications in a document.
How to use <del> e <ins>
<html> <head></head> <body> <p><del>This text is crossed out</del> <ins>and this replaces it</ins>.</p> </body> </html>
For the absolute certainty that the attribute <del> is fully compatible with all browsers, you can add the following code to your CSS.
del {
text-decoration: line-through;
}CSS strike equivalent
The second solution uses only CSS syntax that, thanks to their attribute text-decoration can work around this W3C compatibility problem.
We suffered a practical example:
.strike {
text-decoration: line-through;
}
As for the html code, remember to set strike class on every element you want to delete.
<html>
<head>
<style>
.strike {
text-decoration: line-through;
}
</style>
</head>
<body>
<p>You need only <span class="strike">2</span> 3 rows of CSS code.</p>
</body>
</html>Publication details
Category: CSS
Published by: loryzz on date: 03.11.2008 10:47:34
Last edit by: loryzz on date: 03.11.2008 10:49:06
Ratings
Leave a comment
All comments must be approved by site administrator.
Please write comments on topic. Spam will be never approved.
CSS: Linked articles
Testo lampeggiante published by loryzz in CSS
Table style with css published by loryzz in CSS
Min-width property published by loryzz in CSS
Min-height property published by loryzz in CSS
Proprietà z-index, questa sconosciuta published by loryzz in CSS
























Ritorna all'inizio
Based total comments
0 %
Comments percentage
0 %