उदाहरण
margin शॉर्टहैंड प्रॉपर्टी से चारों मार्जिन एक साथ सेट करें।
<!DOCTYPE html>
<html>
<body>
<button type="button" onclick="display()">चारों मार्जिन सेट करें</button>
<p id="myID">यह डेमो टेक्स्ट है।</p>
<script>
function display() {
document.getElementById("myID").style.margin = "30px 20px 40px 40px";
}
</script>
</body>
</html>
सिंटैक्स: margin: top right bottom left (घड़ी की दिशा में)।
- 1 मान: सभी तरफ
- 2 मान: ऊपर/नीचे, दाएँ/बाएँ
- 3 मान: ऊपर, दाएँ/बाएँ, नीचे
- 4 मान: ऊपर, दाएँ, नीचे, बाएँ