I want to horizontally center a span inside an a-tag. The problem is that I can’t set the height nor the width of the span. My markups is as follows:
<div class="footer">
<a href="#">
<span>Show/Hide</span>
</a>
</div>
And the css:
.footer {position:absolute; bottom:0; width:100%;}
.footer a {display:block; background:orange; text-align:center;}
.footer a span {background:#FFF; font-size:12px; width:100px;}
I’ve tried everything, but think I need some sort of float somewhere, but don’t know. Help are gladly appreciated! 🙂
You can’t set dimensions of
display: inlineelements.You can either have both the a and the span have
display: block, if you want to explicitly set its width:or just use
text-align: centeras you are already doing: