I often see posts in the Microsoft Expression Web discussion forum, asking how to make a web page appear centered in the web browser. One simple method is to surround the contents of your page with a div (if it isn't already), set the div's width, and then set the div's left and right margins to auto. This tutorial shows you how to do all that step-by-step by using the design surface in Expression Web and CSS. The final markup appears at the very end.
[ Note: after posting this tutorial, a colleague pointed out that this solution may not work in Internet Explorer 6. I'll look into this in a few weeks, when I have more time, and either update this post or post a separate addendum. ]
If you're having trouble getting the precise width you want, with your <div> still selected, go to the CSS Properties task pane, and set the width for the selected style. When you drag in Design view to set the width of an element, you set the width in pixel dimensions, but you could set the width of your div to a % value instead if you want the page's width to change relative to the browser window's width. (Note - by default, the selected style will be an inline style on the <div> tag, but if you've modified your CSS options in the Page Editor Options, the selected style is a class. Or if your Style Application mode is set to Manual (not recommended for novices!), you might have a class or tag selector selected.)
Here's the final markup of my page:
<!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled 1</title><style type="text/css"> .style1 { background-color: #CC0066; } </style> </head> <body style="background-color: #CCCCFF"> <div style="width: 395px; margin-left: auto; margin-right: auto;"> <p class="style1"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut nonummy. Suspendisse mi risus, dignissim id, ornare ultricies, venenatis in, sapien. Praesent quis nunc. Sed dapibus. Pellentesque elementum blandit dui. Curabitur elit. Aenean auctor euismod sem. Etiam quis justo id lectus commodo interdum. Maecenas suscipit, ligula ut adipiscing ullamcorper, augue diam suscipit est, et tristique neque nunc quis nulla. Nunc eu mi facilisis lacus cursus elementum. Morbi risus ipsum, dictum non, iaculis imperdiet, ultricies id, neque. Curabitur ac mauris. Nulla sit amet diam. Duis porttitor. </p> </div> </body> </html>