
The CSS margin-bottom property settles the bottom margin of an element.
Demo:
Click the “Try it” button to change the bottom margin of the paragraph (50px):
This is a paragraph.
Syntax:
margin-bottom: auto|length;
auto – the browser calculates a bottom margin.
length – defines a fixed bottom margin in px, cm, etc.
Example:
<!DOCTYPE html>
<html>
<head>
<style>
.ex1 {
margin-bottom: 45px;
}
</style>
</head>
<body>
<p>This is a paragraph.</p>
<p class="ex1">This is a paragraph with a 45px bottom margin.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
Output:
This is a paragraph.
This is a paragraph with a 45px bottom margin.
This is a paragraph.
This is a paragraph.
Enjoy coding!
Read also: