XHTML and CSS strike alternatives

Example of XHTML syntax equivalent to HTML strike attribute, for websites that conform with the W3C standards.

XHTML and CSS strike alternatives

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: loris.genetti on date: 03.11.2008 10:47:34

Last edit by: loris.genetti on date: 03.11.2008 10:49:06

Statistics

Details  This article has been viewed 27.380 times.

Send to

add to digg add to reddit add to furl add to facebook add to delicious add to google add to technorati

Ratings

  • Currently 60; ?>/ TOTALSTARS
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Details 0 user comments, 0 still waiting.

Leave a comment

All comments must be approved by site administrator.
Please write comments on topic. Spam will be never approved.


Confirmation code

Please take a look to image and insert character into the form field.