PDA

View Full Version : Get webppage to centre itself



cymatic_sound
03-07-2006, 12:09 PM
I was wondering if anyone could help me to sort this out. Ive made a webpage so it fits on a 800x600 resolution screen jst to accomodate everyone. As i use 1280x1024 it appears only in the top corner quite small.
Now i am trying to get the page so it will always centre itself no matter what resolution is used and with no side scrolling needed etc. Ive seen websites that do it yet am not sure what part of the code is doing it. If any of you guys know how to do this that would be great.

Cheers

TechMouse
03-07-2006, 03:19 PM
Here is the hacky way to do it:



<html>

<head>
<title>My Webpage</title>
<!-- Other header stuff here -->
</head>

<body>

<table width="100%" height="100%">
<tr>
<td align="center" valign="middle">

<table width="800" height="600">
<tr>
<td>

<!-- Put your page content here -->

</td>
</tr>
</table>

</td>
</tr>
</table>

</body>

</html>


So, essentially what you're doing is creating a single-celled table inside a bigger single-celled table which fills the screen and the content of which is centred both horizontally and vertically.

This is a really horrible way of doing this and you can do it much neater with CSS, but this runs straight out of the box.

cymatic_sound
03-07-2006, 04:32 PM
hey thanks for that , works like a charm. I thought of another question now hoped you might know the answer; i made my webpage design in photoshop , sliced it and save for web - however when i do a W3c web validation thing i get over 70 errors even though it's straight out of photoshop. It mainly seems to be the end markers like > that give the errors and also a randon letter 'c' in a webaddress for a stat counter. I thought it might possibly be to do with the DOCTYPE header stuff but am not sure. ANyone know why photoshop does this or how to fix it ? Actually does the validation thing even matter i just noticed on your site Techmouse you get 2 errors even though there's one thing on it. Here's the validator http://validator.w3.org/



cheers

278d7e64a374de26f==