I want to give a DIV space above and under its content.
How can I do this using CSS?
my DIV code is:
<div class="input">
<label for="pseudo">choisir un pseudo*:</label>
<br>
<input type="text" name="pseudo">
</div>
In case you want additional space ( more than the default ) between div rows then you can add the following code before/after the start of the div row depending on where you want the additional space. This is easier but will add a fixed amount of gap.
The <p class="b"> element has a top and bottom margin of 20px. This means that the vertical margin between <p class="a"> and <p class="b"> should be 50px (30px + 20px).
If you want to avoid CSS, you can use to force an extra space character,   for two spaces, and   for four spaces.
You use the CSS padding
property. In your case you might want to use padding-top
and padding-bottom
alone.
The syntax is the following:
padding: top right bottom left;
or
padding: vertical horizontal;
Some examples:
// This will set the top space to 1px, the right to 2px the bottom to 3px
// and the left to 4px
.input {
padding: 1px 2px 3px 4px;
}
// This will set both the top and the bottom to 20px and the right and the
// left to 10px;
.input {
padding: 20px 10px;
}
// This will set only the bottom space, leaving everything else
// to be automatically determined
.input {
padding-bottom: 20px;
}
Read more about the HTML Box Model
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With