How to vertically and horizontally center text in an unordered list or div

The following example shows you how to vertically and horizontally center text in both an unordered list and a div without resorting to JavaScript or css line heights. No matter how much text you have you won't have to apply any special classes to specific lists or divs (the code is the same for each). This works on all major browsers including IE8, IE7, IE6, Firefox, Chrome, Opera and Safari. There are 2 special stylesheets (1 for IE7 and another for IE6) to help them along due to their css limitations which modern browsers don't have.

If you simply wish for it to work in a div, remove the list items around it (the code will still work).

 
You can view the HTML by clicking 'View source' via your browser.

Here are the links to the stylesheets:
main - Controls all browsers
ie7 - Controls IE7 only
ie6 - Controls IE6 only



If you have any questions or feedback, please email me at: ajfhoward[@t]hotmail.com
Of course replace [@t] with @ this is to stop those automated spammer robots.