I would like to center a DIV tag.
I just have a DIV that’s 838px in width, within the body tags of a HTML page and I would simply like to put in smack bang completely horizontally centered on the page.
body, html {
margin: 0px;
padding: 0px;
text-align:center;
}
body {
background-color:#8ae2ff;
background-image:url(images/bg_image.jpg);
background-position:center bottom;
background-repeat:no-repeat;
background-attachment:fixed;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
#container {
width:838px;
background-color:#FFFFFF;
text-align:left;
}
<body>
<div id="container">
srggdfgsfgfsd
</div>
</body>
I thought it was a simple case of puting margin:auto; in the body part of the CSS. It worked for me before, with an other site, but isn’t now. I don’t know why. Going nuts trying to use DIVs the same way I used tables before. So frustrating.
Can someone please tell me what to do.