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

วิธีทำเครื่องหมายชื่องานผลงาน (Work Title) ด้วยแท็ก cite ใน HTML

แท็ก <cite> ใช้สำหรับระบุชื่องานผลงาน (work title) เช่น หนังสือ เพลง ภาพวาด ภาพยนตร์ โปรแกรมทีวี ฯลฯ Browser จะแสดงเป็นตัวเอียง (italic) โดยค่าเริ่มต้น

การใช้งาน

  • ใช้สำหรับชื่อผลงานเท่านั้น ไใช่ชื่อคน/ผู้แต่ง
  • ชื่อผู้แต่งควรอยู่นอก <cite>
  • สามารถใช้ร่วมกับ <blockquote> หรือ <q> ได้

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <title>HTML cite tag</title>
</head>
<body>
  <h1>Heading</h1>
  <p>
    Learn Java from <cite>Java The Complete Reference</cite> by Herbert Schildt.
  </p>
  <p>
    My favorite movie is <cite>The Matrix</cite> directed by the Wachowskis.
  </p>
</body>
</html>

ผลลัพธ์

Learn Java from Java The Complete Reference by Herbert Schildt.

My favorite movie is The Matrix directed by the Wachowskis.

ความแตกต่าง cite vs blockquote vs q

แท็กวัตถุประสงค์
<cite>ชื่อผลงาน (title of work)
<blockquote>ยกข้อความยาว (block)
<q>ยกข้อความสั้น (inline)