perfectly center a DIV

HTML & CSS Scripts

Author's Comments

Look carefully for specific instructions

This method is pretty basic but very effective essentially you just set the margin to auto and it will make the left and right margins always equal, effectively centering the div.remember i did not find out about this, and i don't take credit for this method.just add that element to the style of any div

Script Code

Copy and paste to HTML


Script Comments

Showing latest 4 of 4 comments

YES!!!! So awesome! Could kiss u! Hope ur a guy(:

By Butterface89 on Jul 22, 2010 1:26 am


By CuntBlog on Dec 27, 2009 2:03 am

Do you know one that will center it vertically?

By emberfly on Jul 3, 2009 12:34 am


By fRESHkiDx on Apr 6, 2009 11:40 am

Script Details

Author alek View profile
Submitted on Mar 28, 2009
Page views 9,460
Favorites 27
Comments 4
Reviewer schizo View profile
Approved on Mar 28, 2009

Script Tags