Jump to content
xisto Community
MediYama

Centering A Div without having to center the content in it

Recommended Posts

Another way to center the div, is by placing it in <center> tags, and adding the following CSS:
text-align: left;

That's correct but the center tag is deprecated and must be avoided, instead to get the similar result you use margin:0 auto as posted in previous posts.

Best regards,

Share this post


Link to post
Share on other sites

Good suggestions from all. Here's another method I personally use with a negative margin. (I like the math! :blink: ) Works in IE6/7, FF, & Opera

#name {position: absolute; left: 50%;width: 600px; margin: 0 0 0 -300px;}

You can use position: relative; if you are centering to a parent element, rather than the browser's window.

Edited by MrSchpfmut (see edit history)

Share this post


Link to post
Share on other sites

Someone posted about the tag <center>. This tag is depricated and is no longer a valid HTML tag (as stated by the W3C - World Wide Web Consortium). So, yes use what TavoxPeru said.Just thought I would let you know!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.