468,505 Members | 1,768 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,505 developers. It's quick & easy.

Centering a Div Horizontally working for all browsers including IE

I have a div container that i have created now i just want to make sure that its horizontally centered in any browser and in any resolution, so that when ever its on 800x600 or 1280x1024 its STILL centered horizontally no matter what, instead of sticking to the left side of the browser window in different res' or window adjusting of any kind.
Thank you kindly
Jan 2 '07 #1
3 2536
7,435 Expert 4TB
In your main container div add margin:0 auto;
Jan 2 '07 #2
<div align="center"></div>
Jan 4 '07 #3
1,892 Expert 1GB
<div align="center"></div>
The align attribute is deprecated here is an example how you can align an element.
[html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<style type="text/css">
background-color: blue;
text-align: center;
height: 250px;
width: 250px;
background-color: white;
border: 1px solid black;


<div class="clsWrapper">
<div class="clsTest">
Hello World

Jan 4 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Jeff Thies | last post: by
19 posts views Thread by George Ziniewicz | last post: by
9 posts views Thread by Pierre Jelenc | last post: by
3 posts views Thread by CMAR | last post: by
6 posts views Thread by Axel Siebenwirth | last post: by
13 posts views Thread by Raffi | last post: by
4 posts views Thread by lister | last post: by
4 posts views Thread by SAL | last post: by
3 posts views Thread by gieforce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.