If you find this helpful, please click the Google Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.) |
The <s> Tag in HTML 5
The HTML <s>
tag for strike out text is used to indicate content that is inaccurate, incorrect or no longer relevant. The s element is one of the phrase elements in HTML. Content inside an s element is often displayed in a strike-through font using a text-decoration: line-through
style property.
The <s>
tag should not be used to indicate a deletion from an HTML document. To provide a standing record of the original text of a blog entry or other actual deletions, the <del> tag should be used instead. The <s> tag should only be used for other purposes, such as:
- to highlight text that is to appear as if it were deleted, sometimes used as humor as in the political correctness "corrections" in
He is
so retardedas dumb as a rock!not so bright. - to mark items as complete in a to do list (although it would be more appropriate to code a
class="complete"
attribute on each item that references a common style with thetext-decoration: line-through
property for the strike-through effect.) - to indicate something that would be considered a mistake if used, as in the examples below.
<s> tag Example
Avoid mismatched quotes in attribute values
Incorrect: <th colspan="3'>
Correct: <th colspan="3">
This shows how the example <s> tag code below would be displayed.
<s> Tag Syntax
<body> ... ... phrasing content expected ...<s>... phrasing content ...</s>... ... </body>
Rules for coding the HTML s
element
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
- Code the s element for strike-through text where phrasing content is expected.
- Begin the s element with a starting <s> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlns
attribute on the <html> tag. - Include any HTML global attributes on the <s> tag as appropriate.
- Inside the s element, between the starting
<s>
tag and the ending</s>
tag, code the inner HTML phrasing content. - End the s element with a matching
</s>
closing tag.
Content Model
Content of the s element
The content of the s element can include HTML comments, text content and only those HTML tags that can be used in phrasing content.
<s> Tag Attributes
Attributes of the <s> tag
global attributes | The only attributes that can be coded on the <s> tag are the common HTML attributes. |
<s> Tag Examples
Examples of the <s>
tag in HTML 5
Example <s> tag to strike text
(see <s> tag demo above)
<h6>Avoid mismatched quotes in attribute values</h6> <p>Incorrect: <s><th colspan="3'></s><br/> Correct: <th colspan="3"></p>
Style alternative to the <s> tag
Instead of using the <s> tag to strike out text, a <span> tag with a class
attribute or style
attribute can be used to display the content with a text-decoration: line-through
property.
Avoid mismatched quotes in attribute values
Incorrect: <th colspan="3'>
Correct: <th colspan="3">
With this approach and alternative style sheets the user can change the style. To see this in action in the example above select the "Incorrect code in red" style from the View -> Page Style menu in Firefox or from the View -> Style menu in Opera or IE.
Changes in HTML 5 - <summary> Tag
What's new in HTML 5
Differences between HTML 5 and earlier versions of HTML
The <s> tag and <strike> tag tag were both deprecated in HTML 4, but the <s> tag may now be used in HTML 5 code. The <strike> tag should never be used, and neither it nor the <s> tag should be used in HTML 4 code until the DOCTYPE declaration is modified to convert to HTML 5.