I have a webpage that is horizontally centered but is rather short – it only takes up half the vertical page. I want it to be centered. How can I center the tag vertically? I cannot have a static height, so that is not an option. if CSS is not powerful enough, can I use Javascript to accomplish this? Thanks!
Share
If you don’t mind adding non-semantic markup, you can do this:
html:
CSS:
http://jsfiddle.net/Jsqqk/
If you do care about semantic markup, and have to support older browsers, then you’ll have to resort to JavaScript for this. Here’s one solution using jQuery:
And here’s the fiddle: http://jsfiddle.net/dw3rc/