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

แอตทริบิวท์ content ของ <meta> ใน HTML


แอตทริบิวท์ content ของ <meta> ใน HTML

แอตทริบิวท์ content ขององค์ประกอบ <meta> ใช้สำหรับตั้งค่าข้อมูลเมตา (meta information) ในเอกสาร HTML สามารถเป็นข้อมูลสำหรับ description หรือ keywords สำหรับแอตทริบิวท์ name

รูปแบบการใช้งาน:

<meta content="text">

โดย text คือข้อมูลเมตา

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <meta name="description" content="เรียนรู้ฟรี">
</head>
<body>
  <h2>บทเรียน</h2>
  <p>บทเรียนโปรแกรมมิ่งฟรี:</p>
  <ol>
    <li>Java</li>
    <li>C++</li>
    <li>C</li>
    <li>C#</li>
  </ol>
</body>
</html>

ผลลัพธ์

แอตทริบิวท์ content ของ <meta> ใน HTML

ในตัวอย่างข้างต้น ภายใต้องค์ประกอบ <head> เราได้ตั้งค่า <meta> description:

<head> <meta name="description" content="เรียนรู้ฟรี"> </head>

คำอธิบาย (description) นั่นคือข้อมูลเมตา ถูกตั้งค่าผ่านแอตทริบิวท์ content ของ <meta>:

content="เรียนรู้ฟรี"