I'm trying to center a button that is an <a>
tag. However, the only thing that will work is the <center>
tag. I've tried using <a style="text-align: center">Button</a>
and <a align="center">Button</a>
, but none of the two worked. Why is it that only the center tag works?
My CSS is this:
.btn {
color: white;
background-color: orange;
padding: 5px;
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
text-decoration: none;
transition: 200ms all;
}
.btn:hover {
background-color: #FFC964;
color: white;
cursor: pointer;
}
HTML:
<a href="http://example.com" class="btn">Button</a>
The
<center>
tag is deprecated and is most likely to be removed in all the browsers. And<a>
tag is inline in nature, sotext-align: center
should be given for it's parent block element:In the above code, the
<div class="make-center">
tag acts as a<center>
tag.