3
Usa display: inline-block;
and the anchor will already respect this padding-top
.
a {
display: inline-block;
padding-top: 80px;
background-color: #2c3e50;
color: white;
text-transform: none;
}
<div>
<a href="">Foo</a>
<a href="">Bar</a>
</div>
The reason it doesn’t work is because the element has display: inline;
and elements inline
do not respect padding
as is expected. By definition the a
is a inline element. There’s an old article about it hereIn English. In that article it says "While padding can be Applied to all Sides of an inline element, only left and right padding will have an Effect on surrounding content.", that is only the side padding is respected.
Examples:
Without changing the display
: https://jsfiddle.net/mnj85kp2/
With display: inline-block;
: https://jsfiddle.net/mnj85kp2/1/
Hello friend would like to know why he does not respect
– Henrique
@Henrique my answer works as you want? I added more info in the answer.
– Sergio
Thanks friend help me a lot.
– Henrique