17. Highlighting Changes
Introduction
Section titled “Introduction”HTML provides elements for indicating changes to documents: <del> (deleted), <ins> (inserted), and <s> (strikethrough). These elements help track document revisions, show edits, and indicate content that has been removed or added. They’re useful for version control, collaborative editing, and showing document history.
Change Elements
Section titled “Change Elements”del (Deleted)
Section titled “del (Deleted)”Marks text that has been deleted:
<p>This is <del>old text</del> updated text.</p>ins (Inserted)
Section titled “ins (Inserted)”Marks text that has been inserted:
<p>This is <ins>new text</ins> in the document.</p>s (Strikethrough)
Section titled “s (Strikethrough)”Marks text that is no longer accurate:
<p>Price: <s>$100</s> $80</p>Common Use Cases
Section titled “Common Use Cases”Document Revisions
Section titled “Document Revisions”<p> Original text <del>deleted portion</del> <ins>new portion</ins>.</p>Price Changes
Section titled “Price Changes”<p> Regular price: <s>$99.99</s> Sale price: $79.99</p>Collaborative Editing
Section titled “Collaborative Editing”<p> Original: <del>old content</del> Updated: <ins>new content</ins></p>Attributes
Section titled “Attributes”datetime
Section titled “datetime”Indicate when change was made:
<del datetime="2024-01-15">Removed text</del><ins datetime="2024-01-16">Added text</ins>Reference source of change:
<del cite="https://example.com/revision">Old text</del>Best Practices
Section titled “Best Practices”Use del and ins Together
Section titled “Use del and ins Together”Show both deletion and insertion:
<p> <del>Old version</del> <ins>New version</ins></p>