Paul McFedries' Web Home


The cover of The Complete Idiot's Guide to Create a Web Page The CIGHTML Mailing List
Frequently Asked Questions - Page Design

Main FAQ page

How do I provide users with an easy way to return to the top of a page?

Right below your <BODY> tag, add the following anchor:

<A NAME="top">

You can then send the surfer to the top of the page by including a link such as this:

<A HREF="#top">Return to the top of the page</A>

How do I create a stationary background that doesn't scroll along with the page text?

Add the BGPROPERTIES=FIXED attribute to your <BODY> tag:

<BODY BGPROPERTIES=FIXED>

You can also do it with style sheets:

<BODY STYLE="background-image: url(http://www.wherever.com/whatever.gif); 
             background-attachment: fixed">
Note, however, that both methods work only with Internet Explorer.

Is it possible to determine the resolution of the user's screen?

Yes, using JavaScript's screen.height property. In the following example, the script checks this property and then replaces the current page with another page that's optimized (presumably) for the user's screen resolution:

<SCRIPT LANGUAGE="JavaScript">
<!--

// Check for 640x480
if (screen.height == '480')
    location.replace('480.html')

// Check for 800x600
else if (screen.height == '600')
    location.replace('600.html')

// Check for 1024x768
else if (screen.height == '768')
    location.replace('768.html')

// Check for 1280x1024
else if (screen.height == '1024')
    location.replace('1024.html')

// Everything else
else
    location.replace('else.html')
//-->
</SCRIPT>

How do I center page text both vertically and horizontally?

You can use <CENTER> to center text horizontally, but there are no HTML tags for centering vertically. However, you can do it if you create a table for your entire page, and then use the VALIGN="MIDDLE" and ALIGN="CENTER" attributes within the main TD tag. Here's the skeleton:

<BODY>

<!--Set up a table for the entire window-->
<TABLE WIDTH="100%" HEIGHT="100%">
<TR>
<TD VALIGN="MIDDLE" ALIGN="CENTER">

<!--The real page text and stuff goes here-->

This text appears smack dab in the middle of the screen.

<!--Close the big table-->
</TD>
</TR>
</TABLE>

</BODY>
See a demonstration.

Main FAQ page


Copyright © 1995-2008 Paul McFedries and Logophilia Limited