| How do I center a block on the page |
|
|
|
| Articles Reviews CSS | |
| Written by Rachel Andrew | |
| Saturday, 17 November 2007 | |
|
A common page layout has a fixed-width centered box that contains the page content, how can we center this box on the page using CSS? You can use CSS to center a fixed-width box by setting its left and right margins to auto. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Centered Box</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="center.css" /> </head> <body> <div id="content"> <p>This is an example text for How do I center a block on the page article </p> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing …</p> </div> </body> </html> body { This technique allows you to center a box easily, and is ideal if you need to center a content block on a page.
Average user rating from: 1 user(s)
Add new review 0 of 0 people found the following review helpful
Thanks!, Wednesday, 02 April 2008 Written by Dave This article helped me immediately and has added a tool to my currently mini css mental toolbox. Not sure how much more time I would have wasted without it. Thanks!
Report this review
Powered by jReviews |
|
| Last Updated ( Saturday, 20 September 2008 ) | |
| < Prev | Next > |
|---|









