Display strikethrough text in HTML



Strikethrough Text

Strikethrough text means text with a line through it. The <strike> tag was used in HTML4 to create a strikethrough text, but it is not supported in HTML5. Instead, the <del> tag is used in HTML5 to define deleted text.

Syntax

Following is the usage of strikethrough tag in HTML ?

<strike>text?. </strike>

Example: Displaying Strikethrough Text

The following example demonstrates the use of the <strike> tag to display strikethrough text. This HTML code creates a webpage with the heading "TutorialsPoint" and a paragraph stating "It is an Edutech Company handles all Technical Non-Technical Subjects," with "Non-Technical" text struck through.

<!DOCTYPE html>
<html>
<body>
   <h2>TutorialsPoint</h2>
   <p>Its an Edutech Company handles all Technical <strike>Non-Technical</strike> Subjects </p>
</body>
</html>

Example: The <del> Tag for Strikethrough Effect

In this example, we are using the <del> tag to achieve the strikethrough effect. This HTML code creates a webpage with the heading "My World" and a subheading" I Like Blue, red, and Pink colors," with the "Red" text struck through and displayed in red color.

<!DOCTYPE html>
<html>
<head>
   <style>
      del {
         color: red;
      }
   </style>
</head>
<body>
   <h1>My World</h1>
   <h2>
      I Like Blue , <del>Red</del>, Pink colors
   </h2>
</body>
</html>

Example: Highlighting Text

We can also use the <ins> tag to highlight text by underlying it. The following example demonstrates the usage of the <ins> tag in HTML. This HTML code creates a webpage with the red heading "My World" and a subheading "I like Orange, blue, red, pink colors!" with the "blue" text struck through and the "red" text inserted.

<!DOCTYPE html>
<html>
<head>
   <style>
      h1 {
         color: red;
      }
   </style>
</head>
<body>
   <h1>My World</h1>
   <h2>
      I Like Orange , <del>blue</del>
      <ins>red</ins>, Pink colors!
   </h2>
</body>
</html>

Example: Incorrect Markup Text

The following example demonstrates markup text that is no longer correct. This HTML code creates a webpage with the red heading "My World" and a subheading "I like red, black colors!" with the text struck through, followed by another subheading "But Everyone likes Pleasant colors."

<!DOCTYPE html>
<html>
<head>
   <style>
      h1{
         color: red;
      }
   </style>
</head>
<body>
   <h1>My World</h1>
   <h2><s>I Like red, black colors!</s></h2>
   <h2>But Everyone likes Pleasant colors</h2>
</body>
</html>
Updated on: 2025-02-12T12:09:48+05:30

796 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements