सीएसएस मार्जिन का उपयोग एलिमेंट के चारों ओर स्थान बनाने के लिए किया जाता है. यदि आप किसी भी Element के Left, Right, Top और Bottom को Clear Spaces देना चाहते है तो आप इस Property का उपयोग कर सकते है. Margins को Define करने के लिए CSS आपको चार Properties Provide करता है.
margin-top
margin-bottom
margin-left
margin-right
यह Property Top Side मे Margins को Define करने के लिए उपयोग की जाती है.
<!DOCTYPE HTML>
<html>
<head>
<title>Margins Top Property Example</title>
<style>
p.margin {
margin-top: 2cm;
}
p.margin2 {
margin-top: 20%;
}
</style>
</head>
<body>
<p class="margin">Wellcome to My Website. My Name is Ammu.
I Live in Telangana.</p>
<p class="margin2">Wellcome to My Website. My Name is Ammu.
I Live in Telangana.</p>
</body>
</html>
यह Property Bottom Side मे Margins को Define करने के लिए उपयोग की जाती है. आप जितनी Value इस Property की देते है उतना ही Space Element के Bottom मे Border के बाहर की तरफ Create हो जाता है.
<!DOCTYPE HTML>
<html>
<head>
<title>Margins Bottom Property Example</title>
<style>
p.margin {
margin-bottom: 2cm;
}
p.margin2 {
margin-bottom: 20%;
}
</style>
</head>
<body>
<p class="margin">Wellcome to My Website. My Name is Ammu.
I Live in Telangana.</p>
<p class="margin2">Wellcome to My Website. My Name is Ammu.
I Live in Telangana.</p>
</body>
</html>
यह Property Left Side मे Margins को Define करने के लिए उपयोग की जाती है जब आप इस Property को Value के साथ Set करते है तो Element के Left की तरफ Border के बाहर Space Create हो जाता है.
<!DOCTYPE HTML>
<html>
<head>
<title>Margins Left Property Example</title>
<style>
p.margin {
margin-left: 2cm;
}
p.margin2 {
margin-left: 40%;
}
</style>
</head>
<body>
<p>Wellcome to My Website. My Name is Ammu.
I Live in Telangana.</p>
<p class="margin">Wellcome to My Website.
My Name is Ammu.</p>
<p class="margin2">Wellcome to My Website.
My Name is Ammu.</p>
</body>
</html>
यह Property Right Side मे Margins को Define करने के लिए उपयोग की जाती है. इससे Element के Right और Border के बाहर की तरफ Specified Space Create हो जाता है.
<!DOCTYPE HTML>
<html>
<head>
<title>Margins Right Property Example</title>
<style>
p.margin {
margin-right: 10cm;
}
p.margin2 {
margin-right: 40%;
}
</style>
</head>
<body>
<p>Wellcome to My Website. My Name is Ammu.
I Live in Telangana.</p>
<p class="margin">Wellcome to My Website.
My Name is Ammu.</p>
<p class="margin2">Wellcome to My Website.
My Name is Ammu.</p>
</body>
</html>