Home
Manage Your Code
Snippet: Horizontal CSS centering (CSS)
Title: Horizontal CSS centering Language: CSS
Description: Center a div element in a parent element. Views: 588
Author: Lars Hedegaard Date Added: 1/9/2008
Copy Code  
<html>
<body bgcolor="black" style="width:100%; text-align:center;">
<div style="width:300px; margin:0px auto;  background-color:white;">
blah
</div>
</body>
</html>
Usage
The parent must have "text-align:center;"
The div must have "margin:0px auto;" and a fixed width (ex. width:300px;)