Beginning HTML5 and CSS3 For Dummies
Book image
Explore Book Buy On Amazon

Links can help users navigate a single web page. Locations within web pages can be marked for direct access by links on the same page. Intradocument hyperlinks include such familiar features as

  • Back to Top links.

  • Tables of contents.

An intradocument hyperlink, also known as a named document link, uses a URL like this:

<a href="#top">Back to top</a>

The pound sign (#) indicates that you’re pointing to a spot on the same page, not on another page.

The listing shows how two anchor elements combine to link to a spot on the same page. (Documents that use intradocument links are usually longer. This document is short so you can easily see how to use the top anchor element.)

<!DOCTYPE html>
<html>
  <head>
    <title>Intradocument Hyperlinks at Work</title>
    <meta charset="UTF-8">
  </head>
  <body>
    <h1><a name="top"></a>Web-Based Training</h1>
    <p>Given the importance of the Web to businesses and other organizations, 
       individuals who seek to improve job skills, or fulfill essential job
       functions, are turning to HTML and XML for training, particularly to 
       HTML5. We believe this provides an outstanding opportunity for 
       participation in an active and lucrative adult and continuing education 
       market.</p>
    <p><a href="#top">Back to top</a></p>
  </body>
</html>

The figure shows how this HTML markup appears in a web browser. If the user clicks the Back to Top link, the browser jumps back to the top spot — marked by . The text for this example is short, but you can see how it works by resizing your browser window (making it tall and narrow) to display only two or three words per line of text.

image0.jpg

About This Article

This article is from the book:

About the book authors:

Ed Tittel is a 30-year veteran of the technology industry with more than 140 computing books to his credit, including the bestselling HTML For Dummies.

Chris Minnick runs Minnick Web Services. He teaches, speaks, and consults on web-related topics and has contributed to numerous books, including WebKit For Dummies.

This article can be found in the category: