Click here to Skip to main content
15,886,095 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Greetings,

I think I`m very new to web development and though I may ask some idiot questions, so please bear with me.

I have developed my web page using Visual Studio 2003, ASP.Net & Visual Basic code. Now what I need is that when I load this web page into the browser it shows in the middle of the browser and not on the left as it is now. Is there any simple way to do so?


Thanks in advance...
Posted
Updated 21-Nov-18 6:18am
Comments
deepakaitr12345 8-Feb-13 7:41am    
Hi..You can use CENTER tag for this try this tag..



Thanks

One way to do it (the way I normally do) is to have a fixed-width container div with its left and right margins set to auto. You can dowload a basic layout:
Here[^]
though you might find its parent gallery [^]useful if you have header and footers etc.

[Edit]

The Html is:
XML
<html>
  <link rel="stylesheet" type="text/css" href="main.css" />
</head>


<body>

   <!-- Begin Wrapper -->
   <div id="wrapper">

         <!-- Begin Content -->
         <div id="content">
            Your main content goes here
         </div>
         <!-- End Content -->

   </div>
   <!-- End Wrapper -->

</body>
</html>

The above creates a div to wrapper (called wrapper) everything you want to put in the middle. It is likely that you will want to put more than one div in this wrapper (for header, content and footer). I have only left the content (called content) in. To center the wrapper on the page (including its child header footer and content) give it a fixed width and set its left/right margins to auto.

The css:

CSS
* { padding: 0; margin: 0; }

body {
	background-color:Green;
}
 
#wrapper {
 margin: 0 auto;
 width: 922px;
 background-color:Red;
}

#content {
 background: Yellow;
}


This is a simplified version of the template in my first link.
 
Share this answer
 
v4
hi.
the <center> tag in html side is simple way to set your page in center.

after <body> tag insert <center> tag and befor end tag </boby> enter </center>.
 
Share this answer
 
Comments
Keith Barrow 20-Feb-12 3:42am    
The center tag is depricated. Most browsers still support it, but thie does not mean that future browsers will.
dgthecodeproject 20-Feb-12 4:00am    
Thanks keith..but what is the replacement for center tag??
Keith Barrow 20-Feb-12 10:12am    
There isn't: W3C admits it should never have been there in the first place as it mixes up the HTML document definition with the layout. See my reply: the thing to do is have a div with its left/right margins set to auto. You can download the html from the link I added to my first answer
you can place your content in a division then align the division in the center. it is a hint. hope it can help. :)
 
Share this answer
 
Comments
dgthecodeproject 4-Mar-12 7:25am    
I did try this thing but with no luck....

Please can you show me sample of this!
use a table inside your form and set it's alignment to "center".
For example:
HTML
<form>
    <table width="900" cellpadding="0" cellspacing="0" align="center">
    </table>
</form>
 
Share this answer
 
v2
Comments
Keith Barrow 19-Feb-12 15:21pm    
At the risk of starting an internecine war, using tables for formatting breaks the semantic meaning of the page. This isn't just theory: accessibility tools (such as screen readers for the blind) use the semantics. Tables are for tabular data.
I've found this link http://www.redefinedwebdesign.com/table-vs-css-layout/ it is less one sided than many pages, but is not as in-depth either. Google "div vs table" layout and you'll see the division (pun intended!) that these two strategies cause.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900