ParagMarku.com

  • Home
  • Themes
  • About
« VU professor gets award for video streaming idea
Useful web-sites »

Center Webpage using CSS

This tutorial explains how to center a webpage horizontally as this page.
Demo: Demo1.
The most commonly used method is the auto-width margin method which I am using.

Unfortunately this method is not directly supported by Internet Explorer. But there is a workaround to achieve it in Internet Explorer.
We add text-align: center;
property to the body element.
This results in all of the text on the page being centered.
To overcome this add text-align: left; to the main division OR the other elements where you want the text to be aligned
to the left.

body {
margin: 50px 0px;
padding: 0px;
text-align: center; /* For IE */
}


div#page {
width: 600px;
margin: 0px auto;
text-align: left; /* For aligning the text to the left */
padding: 15px;
color: #cccccc;
border: 1px solid #666666;
background: #005599;
}

You can see it in action here

Monday, March 5th, 2007 | Code. RSS 2.0 . You can Comment, or trackback from your own site.


Leave a Reply

  • Add to Technorati Favorites

    Subscribe

    Enter your email address:


  • Categories

    • Blog
    • Code
    • Humor
    • Internet
    • Movies
    • Sites
    • Themes
    • Windows
  • Archives

    • June 2007
    • May 2007
    • April 2007
    • March 2007
    • January 2007
    • December 2006

Recent Posts

  • Hacking Firefox: The secrets of about:config
  • Microsoft Unveils Coffee Table Computer
  • Green Shades theme widgetized
  • Green Shades theme released
  • Web messengers lineup

Themes

  • Simple Theme
  • Green Shades

About

Welcome to ParagMarku.com. Site of Parag M. I am a web developer based in Mumbai, India. Find out more about me here.

Hosting Sponsor: Ohawk
ParagMarku.com is proudly powered by WordPress
Entries (RSS) and Comments (RSS).
© ParagMarku.com 2008 Sitemap