Horizontal and vertical centering using html, css without knowing container size

Alec Jacobson

June 17, 2011

weblog/

This is an especially elusive problem when designing a simple webpage in html. There are many non solutions on the web that require knowing the size of the container element. The solution I found was straight forward and did not require knowing anything about the container. It does not require javascript (though the original code uses javascript to show off the fact that it stays centered). A page with horizontal and vertical centering Original source