How to delete text from document using HTML?

In the domain of web development, the capacity to handle text within a file is an indispensable expertise for designing interactive and captivating user interfaces. HTML, the widely recognized coding language utilized for making web pages, furnishes developers with a variety of mechanisms for removing text from a file. Although this may appear to be a simple task, apprehending the fundamental syntax and aspects implicated is fundamental for producing top-quality web applications. In this composition, we shall scrutinize the incremental process of eliminating text from a document utilizing HTML, contemplating on the diverse approaches and deliberations that developers ought to bear in mind. By mastering this dexterity, web developers can engineer more effective and efficient user interfaces, culminating in an overall better user experience.

<del> Tag

The HTML tag labeled as "del" is an encoding component that characterizes text which has been eradicated or eliminated from the manuscript. It is generally employed to specify the modifications or adjustments made in the manuscript. The "del" tag is autonomous and therefore does not necessitate a terminating tag. Upon use, the text confined within the "del" tag would display with a streak across it, denoting that the text has been eliminated. Furthermore, the "del" tag can be coupled with the "cite" characteristic to provide an allusion or acknowledgment for the deletion.


<del>Deleted Text</del>


In order to eliminate any text content present within an HTML manuscript, one can utilize the "del" tag. This particular tag is employed to indicate any fragment of text that has been erased or expunged from the manuscript. Here is a meticulous and sequential scheme for employing the "del" tag to eliminate text content from an HTML manuscript −

  • Unveil the HTML manuscript in a textual or hypertext markup language editor.

  • Discern the textual content that you intend to eradicate from the document.

  • Wrap the text that you want to delete with the "del" tag. This can be done by adding "<del>" before the text and "</del>" after the text.

  • Save the changes to the HTML document.

  • Open the HTML document in a web browser to confirm that the text has been deleted.

It's significant to take note that the "del" tag is infrequently employed in contemporary web development. Alternatively, it's more prevalent to utilize CSS to mask or eliminate constituents from a webpage. Nonetheless, if you're operating on archaic HTML documents or necessitate to obliterate text for a precise reason, the "del" tag can be a pragmatic utensil to hold in your HTML arsenal.


Within the following example, the <del> label is implemented to signify the elimination of text from the document. The CSS property of text-decoration using the attribute of line-through is executed to cross out the text, representing its removal. Furthermore, the color attribute is deployed to set the hue of the eradicated text to the crimson shade.

<!DOCTYPE html>
      <title>How to delete text from document using HTML?</title>
         del {
            text-decoration: line-through;
            color: red;
      <h4>How to delete text from document using HTML?</h4>
      <p>This text will not be deleted.</p>
      <button onclick="addDelElement()">Add del element</button>
         function addDelElement() {
            var delElement = document.createElement('del');
            var textNode = document.createTextNode('This text will be deleted.');


As a final remark, the act of eliminating excessive and unnecessary vocabulary from a textual matter through HTML can be an uncomplicated enterprise when equipped with the suitable expertise and resources. Though the task may appear intimidating initially, it is a valuable aptitude to acquire for individuals aspiring to enhance the intelligibility and comprehensibility of their electronic literature. By means of sagacious application of apt HTML tags, the superfluous lexicon can be expeditiously eliminated, resulting in a refined and pithy end product. By employing these methods, writers can amplify the influence and efficacy of their message, eventually leading to augmented involvement and relevance with their readership.

Updated on: 05-May-2023


Kickstart Your Career

Get certified by completing the course

Get Started