แอตทริบิวต์ HTML lang กำหนดภาษาของเนื้อหาขององค์ประกอบ HTML เป็นแอตทริบิวต์สากลซึ่งหมายความว่าสามารถใช้กับองค์ประกอบ HTML ใดก็ได้
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
<tagname lang=”value”></tagname>
ที่นี่ ค่าแทนรหัสภาษา ISO
ให้เรามาดูตัวอย่าง HTML lang Attribute −
ตัวอย่าง
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background-color: #8BC6EC;
background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
text-align: center;
}
</style>
<body>
<h1>HTML lang Attribute Demo</h1>
<p lang="en">This is a paragraph element with some dummy text and lang attribute.</p>
</body>
</html> ผลลัพธ์
