Within my HTML form, I have a link <a href='...'>...</a>
followed by a label <label ...>...</label>
. I set a bottom margin for the link like this:
form a {
margin-bottom: 10px;
}
When I inspect elements using Google Chrome Console, the a
tag indeed has a margin-bottom
of 10px. But the label is directly below it with no space. How can I generate some space there?
Why margin-bottom doesn't work in this case. Margin-bottom takes space between self and its next element Where bottom is not , it is realtive to the viewport. Bottom property works if elements position is other than relative.
The margin-bottom CSS property sets the margin area on the bottom of an element. A positive value places it farther from its neighbors, while a negative value places it closer.
Adjusting the Margin Size of an HTML Element With CSS You can remove this margin by setting the top and left margin to zero. Like the padding and border, the sizes of specific sides of the margin can be set using margin-left , margin-right , margin-top , and margin-bottom .
By default a
tags are inline elements and therefore can't have margins added. You would need to make your a
tag display like a block element to see margins and other attributes associated with block elements:
form a {
display: block;
margin-bottom: 10px;
}
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