Basics
Creating a Document
Head and Body Elements
Formatting Text
Creating Lists
Embedding Images
URLs Explained
Linking to Documents
Creating Tables
Forms Form Basics
Input and Textarea
Select Lists
Frames Framesets
The Frame Element
Nested Framesets
Targetting Frames
Inline Frames
Tips and Tricks Meta Tags
Transition Effects
HTML Generators Create a Document
Create a List
Create a Table
HTML
Basics
Implementing CSS
CSS Syntax
Pseudo Classes/Elements
CSS Classes
CSS Properties Font Properties
Color and Background
Text Properties
Border Properties
Margins and Padding
Size and Position
Tips and Tricks Menu Buttons
Special Effects
CSS
Basics
Running a Script
Variables
Expressions and Operators
Objects.Properties.Methods
The Date Object
Strings
Regular Expressions
Defining RegExp Patterns
Branches and Conditions
Loops
Arrays Array Basics
Array Methods
Sorting Arrays

User-Defined Functions
Cookies
Windows
Frames
Tips and Tricks Image Replacement
Using Includes
Form Validation
Debugging
JavaScript
Basics
Creating a Script
Running a Script
Variables
Expressions and Operators
Strings Strings Basics
Strings and Substrings
Replacing Substrings
Regular Expressions
Branches and Conditions
Loops
Arrays Array Basics
Array Functions
Sorting Arrays
User-Defined Functions
Include and Require
Uploading Files
File Functions
Session Variables
Tips and Tricks Page Templates
Form Reply Scripts
Form Validation
JavaScript to PHP
PHP
Basics
Create and Drop
Show and Describe
Insert, Update and Delete
Querying
Join Queries
Functions
Table Locking
PHP/MySQL Functions Accessing a Database
Querying with PHP
Create and Drop with PHP
Insert and Update with PHP
Frequently Used Functions MySQL
Basics
Layout and Navigation
Page Content Style
Web Page Copy
Graphics and Animation
HTML Forms
Accessibility
Legal Requirements
MySQL
HTMLBasicsCreating a DocumentHead and Body ElementsFormatting TextCreating ListsEmbedding ImagesURLs ExplainedHTML LinkingLinking to DocumentsCreating TablesForms - BasicsInput and TextareaSelect ListsFramesetsThe Frame ElementNested FramesetsTargeting FramesInline Frames

Home > HTML > Linking to Documentsprinter version

HTML - Linking to Documents

Being able to link to other web pages or web resources is what gives HTML it's power and allows websites to be broken into manageable sized pages instead of one great long page.

To create a hypertext link to another page or resource, the anchor element is used. It takes the form <a href="resource.htm">, has a closing tag and where "resource.htm" is a URL, or address, that points to an available resource on the same, or another, server.


Absolute and Relative URLs

URLs can be absolute or relative to the document root of the server.

Example of an Absolute and a Relative URL
<a href="http://www.mywebsite.co.uk/mypage.htm">my page</a>
<a href="mypage.htm">my page</a>


The advantage of using relative URLs is that if you decide to move all your pages to another domain, you don't need to rename all the absolute URLs that link to pages on your own site.

The anchor element supports a number of attributes the most important of which is target that causes the document referenced to be loaded into a specified window or frame. This takes the form

<a href="mypage.htm" target="window_name">my page</a>

Where "window_name" is a separate browser window, the name of an existing frame in a frameset or one of the four special values listed below.



Some of these values are only useful if you are using frames.

Anchors Within Pages

Anchors within a page allow the user to click a link to jump to a specific part of the same page, which is useful for a long page with many sections.

This involves placing an anchor at the top of the section that you wish the link to jump to and takes the form.

<a name="#this_section">this section</a>
or
<a name="#this_section"></a>


The link that jumps to the anchor above takes the form.

<a href="#this_section">Go to this section</a>


Since "#this_section" is a relative URL it can be expanded to jump to an anchor in another page. This takes the form.

<a href="another_page.htm#this_section">Go to this section on another page</a>


Using Images as Links

It's straightforward to use images as links by substituting an image element for the link text that normally appears within the link. It takes it's most basic form as ...

<a href="mypage.htm"><img src="image.gif></a>


If you rely solely on the image as a link, without any additional text link, then you should make it obvious that it is a link.

In fact the browser will place a border round the image, in the default link colour, if you omit any border attribute within the image element.

If you wish no border then you should set the border attribute to zero.

<a href="mypage.htm"><img src="image.gif border="0"></a>


Image Maps

An image map defines different areas, of a single image, as links to separate resources. The use of image maps is questionable, with regards to usability and accessibility, and so is not covered here.

Previous - HTML URLs explained Previous - URLs Explained     Next - Creating Tables Next - HTML creating tables


Privacy | Terms | Contact | Links | Sitemap | RSS Feeds RSS and JavaScript Feeds
©2010 www.webdesignworkmate.co.uk all rights reserved 
Design and Production by smallbizonline website design © 2000-2010
Valid HTML 4.01! Level Double-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0Valid CSS!
Tips and TricksMeta TagsTransition EffectsHTML GeneratorsCreate a DocumentCreate a ListCreate a Table
Got any HTML Tips?
Send me your tip and if it's suitable I'll put it on the site, credit it to you and add a link back to your site.
Recommended Reading
bullet proof web design

creating web sites

web redesign