New in CSS.
I am trying to center nested divs using the code below
HTML
<html> <head> <title>My website</title> <link rel="stylesheet" type="text/css" href="css/main.css" /> </head> <body> <div id="wrapper"> <div id="formpanel"> <div id="loginForm"> </div> </div> </div> </body> </html>
CSS
body { margin: 0; background : #90ADB7 url('images/background.png') repeat-x; font-family: verdana, sans-serif; font-size: 0.85em; } #wrapper { width: 960px; margin: 0 auto; border-style:solid; padding: 190px 0; } #formpanel { width: 400px; height: 400px; background-color: yellow; margin: auto; } #loginForm { margin: auto; width: 50%; height: 50%; background-color:blue; }
the problem is that the innermost div (#loginForm) is reset with the top edge of the outer div (#formpanel). How do I center the inner div?
Screenshot 
source share