Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NETVB.NET
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 19-Feb-12 1:00am
Comments
deepakaitr12345 at 8-Feb-13 7:41am
   
Hi..You can use CENTER tag for this try this tag.. Thanks
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
<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:
 
* { 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.
  Permalink  
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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>.
  Permalink  
Comments
Keith Barrow at 20-Feb-12 3:42am
   
The center tag is depricated. Most browsers still support it, but thie does not mean that future browsers will.
Dawoodelgharib at 20-Feb-12 4:00am
   
Thanks keith..but what is the replacement for center tag??
Keith Barrow at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

you can place your content in a division then align the division in the center. it is a hint. hope it can help. Smile | :)
  Permalink  
Comments
dgthecodeproject at 4-Mar-12 7:25am
   
I did try this thing but with no luck.... Please can you show me sample of this!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

use a table inside your form and set it's alignment to "center".
For example:
<form>
    <table width="900" cellpadding="0" cellspacing="0" align="center">
    </table>
</form>
  Permalink  
v2
Comments
Keith Barrow at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hello Keith Barrow....
 
I think I got the idea to use the table as a tag in the html..but could you explain more what to do in the design, What I should add in the design form..Is it a table control? or what, where, how? please advise...
 
thanks for your assistance...
  Permalink  
Comments
Keith Barrow at 20-Feb-12 3:47am
   
My advice was *not* to use tables: they break the meaning of the markup, and have several other disadvantages (and some advantages) mentioned in the link I added. There are two schools of thought: use tables for design; don't use tables for design and use divs in with css instead. I follow the second one, as does the W3C, but you need to make your own call on this.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Hello Ahmed Aghili....
 
when I did what you recommend, I got the following error directly in the html tag...
 
"The World-Wide-Web Consortium now regard the elemnt "center" as outdated.Newer constructs are recommended."
 
Please advise...
  Permalink  
Comments
Keith Barrow at 20-Feb-12 3:42am
   
Please see my comment on Ahmad's Answer, this is explains what the W3C mean.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Hello Guys,
 
I just want to clarify an issue here. When I used
I just get that a text of a label is is put in the center and this is not what I need...
 
What I need is that all the webpage with all its controls (labels, textboxex, imageboxex, hyperlinks, etc..) all the stuff should be loaded in the middle of the browser (horizontally).. and that`s it..
 

Thanx guys....
  Permalink  
Comments
Keith Barrow at 22-Feb-12 6:05am
   
First: please do not answer your own questions, unless you have arrived at an answer yourself and want to share it. It is confusing for readers. If you click the "Have a Question or Comment?" button, to the person you want to ask a question to this is much better: they will get an e-mail and you will get a quicker response probably. If you are updating or adding a information to your own question, please click "Improve Question", this means people can see the whole information about the question without looking at the answers.
Keith Barrow at 22-Feb-12 6:08am
   
Second: Please see my updated answer, I have downloaded the code for you and put it here, you should have been able to do this for yourself. If you are unable to understand what I have posted, please consider working through the free tutorials at http://www.w3schools.com/ , which are the best basic introduction to html/css I have yet come accross.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

Greetings,

Thx guys for your tries, but I really need this help from you...
 
@ Keith, I just wanna ask you where is the downloaded code by you in order to try it...& 2nd, I didn`t answer my own question, but just put my unsuccessful try that didn`t work form me....
 

I think you`ve already program this..just need to load my webpage created in Visual Studio 2003 (ASP.Net (VB code)) to be in the middle (only horizontally) when it loads in a browser... and this in the sake to have adds (i.e adsense from google) in the left & right sides of my page (content)...

 
Please advise...

I know you`ve experienced and it may be v.silly but plz provide me with a solution or just a hint....
  Permalink  
Comments
Keith Barrow at 6-Mar-12 5:01am
   
You have just "answered" your own question again: Do not click the "Answer" button (which is what I meant), when trying to contact a member who has answered.Use the "Submit Comment" instead, that way they will get an e-mail telling them you have commented. If you "answer" like this we don't, which is why I'm now replying a week later."Answering" like this also makes things hard to read. I cannot make the answer any clearer: I have put the exact code you need in my original answer, as well as a link to stuff you can download. If you can't work out how this works I suggest you take a course or get help from someone locally because this really is as easy as it gets.
dgthecodeproject at 6-Mar-12 6:04am
   
Sorry keith..It seems that I did something wrong and I know it now. I really understand what you meant...

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 sanket saxena 355
1 Abhinav S 303
2 Sergey Alexandrovich Kryukov 299
3 OriginalGriff 225
4 thatraja 220
0 Sergey Alexandrovich Kryukov 8,497
1 OriginalGriff 4,850
2 Peter Leow 3,839
3 Maciej Los 3,535
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid