Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Margin-bottom does not create space below an <a> tag

Tags:

css

margin

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?

like image 961
Mika H. Avatar asked May 27 '13 20:05

Mika H.


People also ask

Why is my margin-bottom not working?

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.

What does margin-bottom do in HTML?

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.

How do I fix the margin in HTML?

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 .


1 Answers

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;
}
like image 163
nick Avatar answered Oct 20 '22 12:10

nick