ใช้คุณสมบัติ marginLeft เพื่อกำหนดระยะห่างจากขอบซ้ายขององค์ประกอบ ไม่ว่าจะเป็น block หรือ inline element ก็สามารถตั้งค่าได้
ตัวอย่าง
<!DOCTYPE html>
<html>
<body>
<button type="button" onclick="display()">Add left margin</button>
<p id="myID">This is demo text.</p>
<script>
function display() {
document.getElementById("myID").style.marginLeft = "80px";
}
</script>
</body>
</html>