Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

วิธีทำเครื่องหมายข้อความที่เพิ่มเข้ามา (Inserted Text) ใน HTML

แท็ก <ins> ใช้สำหรับทำเครื่องหมายข้อความที่ถูกเพิ่มเข้ามาในเอกสาร สำคัญสำหรับการติดตามการเปลี่ยนแปลงระหว่างเวอร์ชันต่างๆ ของเอกสารเดียวกัน

คุณสมบัติ

  • Browser จะแสดงข้อความด้วยเส้นใต้ (underline) โดยค่าเริ่มต้น
  • มี attribute cite ระบุ URL ที่อธิบายเหตุผลการเพิ่ม
  • มี attribute datetime ระบุวันเวลาที่เพิ่ม (รูปแบบ ISO 8601)
  • ต้องมี opening และ closing tag คู่กัน

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <title>HTML ins tag</title>
</head>
<body>
  <h1>Heading</h1>
  <p>
    This is demo text. <br>
    <ins cite="https://example.com/changelog" datetime="2024-01-15T10:30:00Z">This text is inserted</ins>
  </p>
</body>
</html>

ผลลัพธ์

This is demo text.
This text is inserted

คู่กับ del

สำหรับข้อความที่ลบออก ใช้ <del> (แสดงเส้นทับ) มักใช้คู่กันในระบบ version control หรือ collaborative editing