คุณสมบัติระยะขอบที่มีค่า auto ใช้เพื่อจัดองค์ประกอบในแนวนอนให้อยู่กึ่งกลางในคอนเทนเนอร์ คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้ margin:auto;
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 200px;
margin: auto;
border: 2px dashed blue;
}
</style>
</head>
<body>
<p>This is demo text</p>
<div>
This is horizontally centered because it has margin: auto;
</div>
</body>
</html> ผลลัพธ์
