How to center a website

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

plejon

Thread Starter
Joined
Jul 26, 2001
Messages
671
I would like to design a website that fits on a 640X480 screen, and that is centered horizontally on higher resolution screens.

Samples : www.yahoo.com or www.about.com

How can I design such a site and dynamically center it as I resize the browser window ?
 
Joined
Nov 14, 1999
Messages
628
If you're not sure what centered table code looks like, here's an example ~

^center^^table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH="540" VALIGN="TOP"^
[main body of web page]
^/table^^/center^

(replace ^'s for alternate <>'s)

This code can be seen on this web page ~

http://www.toucan.clara.co.uk/sla/welcome.html
 

plejon

Thread Starter
Joined
Jul 26, 2001
Messages
671
I found an easy way to center my website using frames.

I just define three vertical frames, left, middle, right.
I then set the width for the middle frame to the value I want for my site (E.g. 500 pixels). The width of the left and right frames is set to *. This way, the middle frame will be centered in the window of my browser and even move dynamically if I resize the browser window.

Here's the code I used :

< FRAMESET COLS="*,500,*">
< FRAME SRC="border.html">
< FRAME SRC="content.html">
< FRAME SRC="border.html">
< /FRAMESET>
 
Joined
Nov 14, 1999
Messages
628
I used that method on two previous sites, so I know it works. Say I'm from Bedrock City, if you like, but I'm not a fan of frames and both these sites are now entirely frames-free. Anyway, glad to hear you're sorted. You've shown there's always more than one way to skin a cat.
 

plejon

Thread Starter
Joined
Jul 26, 2001
Messages
671
As you might have guessed, I'm not the world's most seasoned web developer.

I am wondering why so many people are against using frames. I have heard this statement so many times, but never heard any good arguments against the frames.

Personally, I find them very easy to set up the classic style websites with a menu on the left and content on the right. I can develop one menu page, and from that page, open content pages in the content frame.

I haven't been able to figure out how to do this with tables. (Which certainly doesn't mean it isn't possible). So far, I have had to repeat the menu on the left on each of the content pages. That way, if I ever change the menu, I have to go through all content pages to make the change.

So in brief, I have two open questions :
1) what are the advantages of tables vis à vis frames ?
2) how can I work around this menu update problem ?
 
Joined
Nov 3, 2001
Messages
146
The main problems with frames include your page not being listed in search engines properly and the address in the address bar of the browser always staying the same so they don't know the exact address of the exact page they're on. Also the scroll bar in the frames will be in the middle of the screen (sort of) rather than at the side of the screen.

What you've done with frames is *much* more complicated than using tables. The code you need (so it looks the same as you've got it with frames but without frames) is:

&lt;DIV ALIGN="center"&gt;
&lt;TABLE BORDER="0" WIDTH="500" CELLSPACING="0" CELLPADDING="0"&gt;
&lt;TR VALIGN="top"&gt;
&lt;TD&gt;

This is a table cell - you put the content you want to be centered here.

&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TABLE&gt;
&lt;DIV&gt;

You need to use tables for lots of things in webdesigning, you can learn how to do them (basic, harder and different kinds) here: http://hotwired.lycos.com/webmonkey/authoring/tables/ or http://www.lissaexplains.com/table.shtml

The menu thing *can* be done with tables but it means that you have to update the links on each page when you change the pages on your site, but this *can* be done in one go like with frames - http://www.lissaexplains.com/html6.shtml

I hope this helps.
 
Joined
Nov 14, 1999
Messages
628
Xfilesgurly makes some good points, especially in respect to the scroll bars (but that depends on how deep your page is).

The menu updates can be made easier by using a HTML editor that allows 'find and replace' over a number of files (e.g. Cute HTML). If all the menus are identical then you only need to change one page.

A drawback of frames is that you cannot go to a target within a frame from outside the frame. Try it, it doesn't work for me. And believe it or not, there are people out there who can't see frames because they are still using old browsers. Are you bothered about this?

My advice would be to keep the pages simple and not use frames unless you really need to.
 

plejon

Thread Starter
Joined
Jul 26, 2001
Messages
671
Thanks a lot for the feedback.

The SSI were new to me.
 
Joined
Nov 3, 2001
Messages
146
A drawback of frames is that you cannot go to a target within a frame from outside the frame. Try it, it doesn't work for me.
Do you mean this:

&lt;A HREF="page.html#gohere' TARGET="right"&gt;whatever&lt;/A&gt; (In the navigation frame)

&lt;A NAME="gohere"&gt;whatever&lt;/A&gt; (on page.html in the frame named "right")

?
 
Joined
Nov 14, 1999
Messages
628
The code looks familiar but in basic terms, the site had a mix of framed and non-framed pages and I couldn't get a link to jump me from an unframed page to a specific target within a framed page. The result would get me to the top of the frame but not directly to the target.

I placed this query with the forum but nobody had a solution beyond creating ghost pages with refreshes(!) or accepting the visitor had to make two jumps. I dumped the frames.

By the way, how did you get your code to show up in the forum? Whenever I try, it doesn't show.
 

plejon

Thread Starter
Joined
Jul 26, 2001
Messages
671
I was able to post HTML by inserting a space between the < and the actual tag.

But I'm sure xfilesgurly knows a better way ...
 
Joined
Nov 14, 1999
Messages
628
Ok, I've just reposted some of the code above and here is the result ~
~~~~~~~~~~~~~~~~~~~~~~
[here should be xfilesgurly's the target link code]
<A HREF="page.html#gohere' TARGET="right">whatever</A> (In the navigation frame)

<A NAME="gohere">whatever</A> (on page.html in the frame named "right")

~~~~~~~~~~~~~~~~~~~~~~
[here should be xfilesgurly's table code]
<DIV ALIGN="center">
<TABLE BORDER="0" WIDTH="500" CELLSPACING="0" CELLPADDING="0">
<TR VALIGN="top">
<TD>

This is a table cell - you put the content you want to be centered here.

</TD>
</TR>
</TABLE>
<DIV>
~~~~~~~~~~~~~~~
[here should be plejon's frame code]
< FRAMESET COLS="*,500,*">
< FRAME SRC="border.html">
< FRAME SRC="content.html">
< FRAME SRC="border.html">
< /FRAMESET>
~~~~~~~~~~~~~~~~~~#
 

plejon

Thread Starter
Joined
Jul 26, 2001
Messages
671
I can only see my code.

Notice there is a space between < and FRAME in my code
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Top