Ilja Ilja - 1 year ago 71
HTML Question

Vertically center <a> tag?

I'm struggling to vertically centre tag in of of the elements.

What I've got is something like:

header {padding: 20px 0 20px 0; clear: both;}
header a {
float: right;
vertical-align: middle;
margin: auto 0 auto 0;
//This is what I tried, doesnt work

<a href="#">Center Me Please!</a>
<p> Stack Overflow </p>

I just can't figure auto ho to fix that tag in the header

Answer Source

To Center a without taking in consideration the other contents of the container, use absolute positioning.

    top: 50%; // nearly 50%, but not exactly 50%
    left: 50%;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download