แอตทริบิวต์ตัวยึดตำแหน่ง HTML แทนข้อความที่แสดงใน อินพุต/พื้นที่ข้อความ ก่อนที่ผู้ใช้จะเริ่มป้อนข้อมูลใดๆ
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
<tagname placeholder=”text”></tagname>
ให้เราดูตัวอย่างของแอตทริบิวต์ตัวยึดตำแหน่ง HTML -
ตัวอย่าง
<!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 placeholder Demo</h1>
<input type="text" placeholder='Enter your first name'>
<input type="text" placeholder='Enter your last name'>
</body>
</html> ผลลัพธ์
