Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
The easiest possible method:
.elem {
height: 400px;
position: absolute;
top:50%;
margin-top:-200px;
}
Of course there are other methods:
<a>
<b></b>
</a>
a{ display:table;}
b{display:table-cell; vertical-align:middle;}
It's easy xD -
now if you talk about center aligning a dynamic width element like a navigation which changes width every time a new item is added. That is difficult xD
-
@uziiuzair I appreciate the advice! I guess my initial point was that vertical alignment, though achievable by a number of overly-complicated methods (like your solutions, or Flexbox, or CSS Grid), it is far more complicated than it ever needed to be.
In fact, what I'd really love to hear is a convincing argument as to why the "vertical-align" property was designed exclusively to work only with inline or table-cell elements. -
@blizzrdof77 now that you have mentioned it. Yes I too would love to know why the properties exist. This certainly couldve been made simpler.
Related Rants

What only relying on JavaScript for HTML form input validation looks like
How to vertically center in css..
Found something true as 1 == 1
This still blows my mind..
undefined
html
funny
vertical alignment
css