facebook twitter youtube
in Css - 17 Mar, 2014, This Tutorial Has Been Viewed 7,273 Times.
by admin - no comments
Center or align a webpage completely in any browser using simple CSS and HTML
VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)

This is a quick tip on how to center a webpage completely using CSS and HTML. Here we are using div tag for centering the entire content inside webpage.

 <div id="outer-div-main">
    <!-- your website contents here --> Hi guys,
<p>
This content will be aligning to the center of the webpage. This works good on internet explorer, Mozilla and Chrome. So please go-ahead and implement the script if you find it easy and straight forward.
  </div>

Add this CSS code just inside the body tag

body
{
text-align: center;
}
#outer-div-main
{
text-align: left;
width: 1024px;
margin: 0 auto;
}

Create an html file and put all the above code together. Sample below

<html>
<body>
<style>
body
{
text-align: center;
}
#outer-div-main
{
text-align: left;
width: 1024px;
margin: 0 auto;
}
</style>
<div id="outer-div-main">

    <!-- your website contents here --> Hi guys,
<p>
This content will be aligning to the center of the webpage. This works good on internet explorer, Mozilla and Chrome. So please goahead and implement the script if you find it easy and straight forward.
  </div>
</body>
</html>

This script is compatible with all the latest browsers.

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)
Center or align a webpage completely in any browser using simple CSS and HTML, 10.0 out of 10 based on 1 rating

Leave a Reply

Close
Please support the site
By clicking any of these buttons you help our site to get better