Slide 2.13: HTML links
Slide 2.15: HTML images
Home

HTML Links (Cont.)


The name Attribute
The name attribute is used to create a named anchor. When using named anchors we can create links that can jump directly into a specific section on a page, instead of letting the user scroll around to find what he/she is looking for. Below is the syntax of a named anchor:
   <a name="label">Text to be displayed</a>
The name of the anchor can be any text you care to use. The line below defines a named anchor:
   <a name="demo">Demonstration</a>
You should notice that a named anchor is not displayed in a special way. To link directly to the “demo” section, add a # sign and the name of the anchor to the end of a URL, like this:
   <a href="http://undcemcs01.und.edu/~wen.chen.hu/course/260/
       2/13.html#demo">Jump to the Demonstration</a>
A hyperlink to the Demonstration from within this file looks like this:
   <a href="#demo">Jump to the Demonstration</a>

Basic Notes—Useful Tips
Always add a trailing slash to subfolder references. If you link like this:
   href="http://www.w3schools.com/html"
you will generate two HTTP requests to the server, because the server will add a slash to the address and create a new request like this:
   href="http://www.w3schools.com/html/"
Named anchors are often used to create “table of contents” at the beginning of a large document. Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the document.

Demonstration
The following demonstration shows how the HTML script is displayed on the Web.