Mahaveer sharma Mahaveer sharma - 5 months ago 28
HTML Question

CSS margin not working right

Can someone please tell me , why i can't add margin-top/bottom or padding-top/bottom to this "a" tag.
I need to ceter "Konoha" in the Header box

<body>
<header class = "top-box">
<a href="#">Konoha</a>
</header>
</body>


the CSS is

html{
background-color: white
}


body{
width: 88.5%;
height: 1200px;
margin: 0 auto;
border: 2px solid black;
background-color: #161e2c;
}

.top-box{
margin:0 auto;
width: 99.5%;
height: 153px;
background-color: #314e59;
border:1px solid rgb(211, 41, 97);
box-shadow: 0px 10px 7.4px 2.6px rgba(0, 0, 0, 0.74);
}

a{
color: white;
text-decoration: none;
font-size: 100px
}

Answer

anchor is a inline element if you want to use padding-top/bottom, you should using add display:block for anchor tag

a{
color: white;
text-decoration: none;
font-size: 100px;
display:block
}

readmore

Comments