My Hobbies and Need To Get Up Early.
My Hobbies and Need To Get Up Early.
}
</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>
<!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>
<!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>
<!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