How to Strikethrough Text in HTML: Simple Syntax and Examples
To strikethrough text in HTML, use the
<s> or <del> tags around the text you want to cross out. Both tags visually show a line through the text, indicating it is deleted or no longer relevant.Syntax
The basic way to strikethrough text is to wrap it inside the <s> or <del> tags.
<s>...</s>: Shows text with a line through it, often used for content that is no longer accurate.<del>...</del>: Represents deleted text, also shown with a strikethrough.
html
<s>strikethrough text</s> <del>deleted text</del>
Output
strikethrough text
deleted text
Example
This example shows how to use the <s> and <del> tags to strikethrough text in a simple HTML page.
html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Strikethrough Example</title> </head> <body> <p>This is <s>strikethrough</s> text using the <s> tag.</p> <p>This is <del>deleted</del> text using the <del> tag.</p> </body> </html>
Output
This is strikethrough text using the s tag.
This is deleted text using the del tag.
Common Pitfalls
Some common mistakes when trying to strikethrough text in HTML include:
- Using the
<strike>tag, which is deprecated and should be avoided. - Trying to use CSS
text-decoration: line-through;without understanding it requires a style attribute or stylesheet. - Not closing the tags properly, which can break the HTML structure.
html
<!-- Wrong: Deprecated tag --> <strike>old way</strike> <!-- Right: Modern tag --> <s>correct way</s>
Output
old way
correct way
Quick Reference
| Tag | Purpose | Status |
|---|---|---|
| Strikethrough text | Current standard | |
| Deleted text with semantic meaning | Current standard | |
| Strikethrough text | Deprecated, avoid using |
Key Takeaways
Use or tags to strikethrough text in HTML.
Always close tags properly to avoid HTML errors.
Use when you want to show deleted content semantically.
For styling, CSS text-decoration: line-through can also create strikethrough.