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

ทำไมต้องใช้แท็ก head ในหน้า HTML?

แท็ก <head> เป็น container สำหรับ head elements ทั้งหมดในหน้า HTML การเพิ่มแท็ก <head>...</head> ทำได้ง่าย เพิ่ม title ของเอกสาร หรือ meta information, styles, scripts, ฯลฯ

จำไว้ว่า แท็ก <title>...</title> ถูกเพิ่มภายในแท็ก <head>...</head>

ทำไมต้องใช้แท็ก head ในหน้า HTML?

ตัวอย่าง

<!DOCTYPE html> 
<html> 
  <head> 
    <title>HTML head tag</title> 
  </head> 
  <body> 
    <h2>Working with HTML head tag</h2> 
    <p>This is demo text.</p> 
    <p>Displaying how head tag is used in HTML. Add title in it or meta information about the document.</p> 
  </body> 
</html>

ผลลัพธ์

ทำไมต้องใช้แท็ก head ในหน้า HTML?