HTML TIPS AND TRICKS

  Tip 1: How to make some text links appear in different color from what is defined in BODY tag.
The trick is to put the <FONT COLOR> tags inside the <A> tags like below:
<A HREF="link.html"><FONT COLOR="#FF00FF">Link</FONT></A>

If you have the <FONT COLOR> tags outside the <A> tag (such as below), then it will not work (i.e.: the link will be displayed using the default or the link color you specify within the BODY tag).

<FONT COLOR="#FF00FF"><A HREF="link.html">Link</A></FONT>

Note that <FONT> tag is not a standard html tag.  However, it is supported on most browsers.


 
  Tip 2: How to make text-links glow/highlighted.
Use style-sheet like this:  
<HEAD><TITLE>.....</TITLE>
<STYLE>
<!--
a:hover
{
 background: rgb(0,153,204); /*or any rgb value */
}
//-->
</STYLE>
</HEAD>

This should work on Internet Explorer 5 or newer.  However, the a:hover pseudo class is currently not supported by the official CSS 1.0 specification, and it does not work on Netscape 4.7 or older.  If you must have something like this on Netscape, your options will be to use JavaScript rollover or Java applet.


 
  Tip 3: How to add blank spaces between words.
The html specification specifies that any extraneous blank spaces that appear between words should be ignored.  So you need to use a special code: &nbsp; instead of entering the spaces directly between words.  Each &nbsp; represent one non-breaking spaces, if you want more than one, enter as many as you need.  

 
  Tip 4: How to properly add comments in html code.
Generally, comments in html code can be inserted within a "<!--"   " -->" tag.  For example:
<HTML><HEAD><TITLE>Title</TITLE></HEAD>
<BODY>
My web page.
<!-- this is a comment -->
</BODY></HTML>

Some caution when commenting: avoid using any "--" within the comment.  Double dashes within a comment might be considered as the end of the comment by some browsers (even though officially, comments end with a "-->").  So, for example, try to avoid something like this:

<!-- this is a comment -- there are two dashes in the middle of this comment -->
 


 
Tip 5: How to get rid of the border on an image link.
Specify BORDER="0", like this
<A HREF="link.html"><IMG SRC="image.gif" 
WIDTH="200" HEIGHT="20" BORDER="0"></IMG></A>

  Tip 6: How to prevent directory listing being shown on a web browser.
The simplest way is to put a dummy index.html file on that directory.   This will work because the browser always searches for default files (such as index.html, index.htm, or default.html); if it cannot find any of them, then it might display the directory listing (if directory listing feature is enabled).

Another way is to set the directory permission so it's not world-readable, but make it world-executable (e.q.: chmod o+x o-r dirName).  (Note: this may not work depending on your server.)  

Another way is to disable directory listing through the server.  You need to have access to the server to do this, and I don't think all servers support this feature.

None of these will prevent user from reading that file from the directory (if the file is already accessible from the web browser).  If user know the filename on the particular directory, he/she can still access that file by typing the fill name on the browsers URL prompt.


 
 

Tip 7: When user types on my text field, the text does not wrap but scroll to the right side of the text field.   This looks bad... how can I make the text wrap?
Use WRAP="VIRTUAL" like this example:

<TEXTAREA NAME="ANAME" ROWS="5" COLS="56" WRAP="VIRTUAL"></TEXTAREA>

VIRTUAL means that anything that the user enter will be wrapped when it reaches the end of the allocated width of the text field.  However, when the form is submitted, the wrapping will not be preserved.  To preserve the wrapping, use WRAP="PHYSICAL" 

 


 
 

Tip 8: What is the correct way to print ©, or other special characters?
Many web page authoring program already has an option that enables you to insert special characters.  For html hard-coder purists, these special characters need to be coded with their corresponding "name-code."  Below are the most common special characters along with their corresponding name codes.  

COMMONLY USED SPECIAL CHARACTERS

 

©

&copy;

 

°

&deg;

 

®

&reg;

 

½

&frac12;

 

&

&amp;

 

¼

&frac14;

 

<

&lt;

 

¾

&frac34;

 

>

&gt;

 

÷

&divide;

 

±

&plusmn;

 

£

&pound;

 

"

&quot;

 

¥

&yen;

 

¹

&sup1;

 

§

&sect;  

 

²

&sup2;

 

¢

&cent;

 

³

&sup3;

 

¬

&not;

(You can also use the corresponding ISO 10646 character code.  ISO 10646 the standard character-set for the www.  For example, use &#169; for copyright sign, but unless you have an ISO table/reference handy, it's easier to remember the name-codes.)    The www consortium has a list of character coded in http://www.w3.org/TR/html401/sgml/entities.html.


 

F. Permadi, March 1999

<<BACK>>