HTML s Tag: How it Works with Examples

html s tag

The HTML s tag places a line across text that has no longer value or does not hold importance. It helps readers see words that lost meaning in a direct way.

What is the <s> Tag in HTML?

The <s> tag draws a strike line across text. It marks text that should not carry weight but still must remain visible on the page.

Here is the basic tag:

<s>Old price</s> New price

The tag above keeps the word “Old price” but shows it as crossed out.

Here is a quick example:

<p>My favorite color is <s>blue</s> red.</p>

The output shows “blue” with a strike line and “red” as the new value.

The Difference Between <s> Tag and <del> Tag

The <s> tag strikes text for style and meaning shift. The text stays, but looks marked as not valid.

The del tag means the text was deleted. It shows removed content in a semantic way for screen readers and search engines.

Here is a table that shows you the key differences between them:

TagUseSemantic roleScreen readers
sStrike words with no valueNoneSkip meaning
delMark text as deletedYesReads as deleted

You use the s tag when you want to show words that lost weight but must still remain. The del tag fits when you want to mark removed text in a document or revision.

The s tag works in all modern browsers such as Chrome, Firefox, Safari, Edge, and Opera. Old versions of Internet Explorer also support it.

How to Style the <s> Tag with CSS

You can style the s tag with CSS. You may change the strike line color, style, or even replace it with a custom design.

s {
  color: gray;
  text-decoration: line-through red;
}

This rule paints the strike line red and the word gray.

Examples of <s> Tag in HTML

Old price with new price:

<p><s>$100</s> $80</p>

This shows the first price with a strike line and the second price as the valid one. The reader sees the discount in a direct way without words.

Corrected word in a sentence:

<p>He moved to <s>London</s> Paris last year.</p>

This marks the first word as not valid and keeps Paris as the right city. It does not delete the old word from view.

Custom style with CSS:

<style>
s {
  text-decoration: line-through double blue;
  font-weight: bold;
}
</style>
<p><s>Closed</s> Open Now</p>

This uses a double blue strike line and bold text. It adds more weight to the visual change and guides readers to the valid state of the message.

Show old rules on a notice board:

<p><s>No entry after 9 PM</s></p>
<p>New entry rule: open until midnight</p>

The first rule remains struck to show that it lost value, and the new rule is displayed below. This method helps when you update public rules or notes.

Wrapping Up

In this article, you understood how to use the tag and the differences between it and the tag in HTML.

Here is a quick recap:

  • The <s> tag helps you to put a line through the text that is no longer important but still visible.
  • The <del> tag marks deleted text and has semantic use.
  • You can style the strike line with color.

FAQs

What does the <s> tag do in HTML?

The <s> tag renders text with a strikethrough to show that the text is no longer accurate or relevant. Example:
<p>Old price: <s>$50</s></p>

How is <s> different from <del> in HTML?

<s> is for marking text as outdated without implying removal from the document. <del> implies content removal, often with a datetime attribute. Example:
<p>Old: <s>Feature X</s>, Removed: <del datetime="2025-01-01">Feature Y</del></p>

Can you style the <s> tag with CSS?

Yes, you can style the <s> tag with CSS for custom colors or effects. Example:
<style>
s { color: red; text-decoration: line-through; }
</style>
<p>Outdated: <s>This offer</s></p>

Is the <s> tag supported in all browsers?

The <s> tag is supported in all major browsers including Chrome, Firefox, Edge, Safari, and Opera without additional setup.

Similar Reads

HTML script Tag: How to Add JavaScript to a Web Page

The script tag adds JavaScript to a web page in HTML. This lets the page run logic or load content.…

HTML Introduction for Beginners from Scratch

HTML is the main content for every web page. It helps you structure text, links, and media. You can build…

HTML noscript Tag: How to Display Fallback When JS Is Disabled

The HTML noscript tag tells the browser what to show when JavaScript does not run. This tag targets users who…

HTML a Tag: How to Add Links to Web Page with Examples

The HTML a tag allows you to create links that move users from one page or resource to another. Understand…

HTML abbr Tag: How Abbreviations Work with Examples

The abbr tag refers to an abbreviation in HTML. It helps you save space and improve accessibility. The screen readers…

HTML Article Tag: How to Create Semantic Content

Semantic article tag in HTML uses clear tags that show the role of each part. These tags tell browsers and…

HTML Section Tag: How It Works with Examples

The HTML section tag groups parts of a web page that share one theme. It gives clear meaning to content.…

HTML Nav Tag: How to Create Navigation Menus

The nav tag defines a navigation block in HTML. It holds main links to other parts of your site. Search…

HTML Aside Tag: How to Create a Side Content

You use the <aside> tag to mark extra content in HTML. It does not replace the main text and shows…

HTML i Tag: How to Make Text Italic

The <i> tag stands for "italic." It marks text that has a different voice or tone, such as a technical…

Previous Article

PHP array_push Function: How it Works with Examples

Next Article

Understanding JavaScript Objects with Examples

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *


Subscribe to Get Updates

Get the latest updates on Coding, Database, and Algorithms straight to your inbox.
No spam. Unsubscribe anytime.