We Recommend

CSS: The Definitive Guide CSS: The Definitive Guide
Provides you with a comprehensive guide to CSS implementation, along with a thorough review of all aspects of CSS 2.1. Updated to cover Internet Explorer 7, Microsoft's vastly improved browser, this new edition includes content on positioning, text wrapping (nowrap), lists and generated content, table layout, user interface, paged media, and more.


Posted By

indianocean on 06/04/07


Tagged

css textmate alignment


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

basicmagic
vali29


Horizontally center a box


Published in: CSS 


  1. margin-left: auto;
  2. margin-right: auto;
  3. width: 400px;

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: jonhenshaw on June 4, 2007

I don't think you need the "position" for this, and you can make it smaller by writing it like this: "margin:0 auto;width:400px;"

Posted By: indianocean on June 4, 2007

jonhenshaw, you are right with 'position', but I prefer to have a single statement per line ;-) Thanks

You need to login to post a comment.