The <ins> tag in HTML is used to indicate that a portion of text has been inserted into a document. This can be useful in a variety of situations, such as when you need to show changes made to a document or when you want to highlight new or added content. In this tutorial, we will explain how to use the <ins> tag in HTML and provide examples of its usage.
Syntax:
The basic syntax for the <ins> tag is as follows:
<ins>inserted text</ins>
Attributes:
The <ins> tag supports several attributes, including:
– `cite`: Specifies the source of the inserted text. This can be a URL or other identifier.
– `datetime`: Specifies the date and time when the inserted text was added to the document. This should be in ISO 8601 format.
Examples:
Let’s take a look at some examples of how the <ins> tag can be used in HTML.
Example 1: Basic Usage
In the following example, we have a document that has been updated with new content. We use the <ins> tag to indicate which text has been inserted:
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut auctor, massa vel bibendum tristique, <ins>justo quam facilisis ex</ins>, id consectetur nibh ipsum non nulla.</p>
This will display the following text with the inserted text underlined:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut auctor, massa vel bibendum tristique, <ins>justo quam facilisis ex</ins>, id consectetur nibh ipsum non nulla.
Example 2: Using the `cite` Attribute
In this example, we use the `cite` attribute to specify the source of the inserted text:
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut auctor, massa vel bibendum tristique, <ins cite=”https://example.com/changes.html”>justo quam facilisis ex</ins>, id consectetur nibh ipsum non nulla.</p>
This will display the following text with the inserted text underlined and a link to the source:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut auctor, massa vel bibendum tristique, <ins cite=”https://example.com/changes.html”>justo quam facilisis ex</ins>, id consectetur nibh ipsum non nulla.
Example 3: Using the `datetime` Attribute
In this example, we use the `datetime` attribute to specify when the inserted text was added to the document:
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut auctor, massa vel bibendum tristique, <ins datetime=”2023-04-24T12:00:00Z”>justo quam facilisis ex</ins>, id consectetur nibh ipsum non nulla.</p>
This will display the following text with the inserted text underlined and the date and time displayed:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut auctor, massa vel bibendum tristique, <ins datetime=”2023-04-24T12:00:00Z”>justo quam facilisis ex</ins>, id consectetur nibh ipsum non nulla.
Conclusion:
The <ins> tag in HTML is a useful tool for indicating that text has been inserted into a document. By using the <ins> tag and its attributes, you can provide additional information about the inserted text, such as its source and when it was added. This can be especially helpful when collaborating on a document with others or when making updates to a website.