Center a Div and other HTML blocks

CSS can often be tricky.  What do we need to do to get all those pesky browsers to show things the way we want?!  Sometimes, I marvel at the patience of people who find out, after hours, just how to nudge something properly one way or get the body of text to flow and display just the way they’re asked to do it.  So, something so basic, why is it sometimes so much trouble?  And do we need to write all this just to center a block?!  Why can’t we just say “align:center”?!  Don’t get me started on VERTICAL alignment, that’s not nearly as easy as table cells made such a trick out to be….

Add this to any of your CSS or inline where needed and make sure no other margins are defined:

Note:  Be sure a width and height of this block element is also defined!

This entry was posted in   CSS.
Bookmark the   permalink.

Aaron Belchamber has written 243 articles

Leave a Reply

Your email address will not be published. Required fields are marked *