0% found this document useful (0 votes)
30 views2 pages

My Hobbies and Need To Get Up Early.

Uploaded by

Prem Lal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

My Hobbies and Need To Get Up Early.

Uploaded by

Prem Lal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

lightblue;

}
</style>
</head>
<body>
<h2>The margin shorthand property - 3 values</h2>
<div>This div element has a top margin of 25px, a right and left
margin of 50px, and a bottom margin of 75px.</div>
<hr>
</body>
</html>

Use shorthand margin property with two values

<!DOCTYPE html>
<html>
<head>
<style>
div{
border: 1px solid black;
margin: 25px 50px;
background-color: lightblue;
}
</style>
</head>
<body>
<h2>The margin shorthand property - 2 values</h2>
<div>This div element has a top and bottom margin of 25px, and
a right and left margin of 50px.</div>
<hr>
</body>
</html>

Use shorthand margin property with one value

<!DOCTYPE html>
<html>
<head>
<style>
div{
border: 1px solid black;
margin: 25px;
background-color: lightblue;
}
</style>
</head>
<body>
<h2>The margin shorthand property - 1 value</h2>
<div>This div element has a top, bottom, left, and right margin
of 25px.</div>
<hr>
</body>
</html>

Set margin to auto to center the element within its container


<!DOCTYPE html>
<html>
<head>
<style>
div{
width: 300px;
margin: auto;
border: 1px solid red;
}
</style>
</head>
<body>
<h2>Use of margin: auto</h2>
<p>You can set the margin property to auto to horizontally
center the element within its container. The element will then
take up the specified width, and the remaining space will be split
equally between the left and right margins:</p>
<div>
This div will be horizontally centered because it has margin: auto;
</div>
</body>
</html>

Let the left margin be inherited from the parent element

<!DOCTYPE html>
<html>
<head>
<style>
div{
border: 1px solid red;
margin-left: 100px;
}
p.ex1{
margin-left: inherit;
}
</style>
</head>
<body>
<h2>Use of the inherit value</h2>
<p>Let the left margin be inherited from the parent
element:</p>
<div>
<p class="ex1">This paragraph has an inherited left margin
(from the div element).</p>
</div>
</body>
</html>

Margin collapse

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy