This tutorial will show you mainly how versatile the anchor element (e.g., <a href= "">Link Text</a>) is. Beside using it to create a navigational bar (See Horizontal and Vertical Menus) using CSS, the <a> tag has many other uses to help a user navigate the web.
Creating a regular text link is the hallmark of any web site/web app. There are ten ways to a regular text link which allows you to navigate from one page to another.
Simply select a word or multiple words you want to convert to a link and then:
From the Properties Panel:
From the File Panel:
EXAMLPLE: Click this link.
NOTES:
There are three type of links.
NOTES:
There are several options when targeting a link you create:
There are four major link states color or graphic that can be styled with CSS:
TIP: When using an acronym, it is best practice to use a dotted line instead of a solid line which are usually reserved and understood as links.
An image link is basic the same as a regular text link. The different is that the <a> tags are wrapped around an <img> tag instead of some text. The <img> tag is a self-closing tag like the <br />, <hr />, <link /> and <input /> tags:
<a href="anotherpage.html"><img src="image.jpg" /></a>
An email link is also similar to a text or image link. The different is that the href attribute is set to an email address prefixed by a mailto: protocol instead of a HTML file name (e.g., myfile.html) or http protocol (e.g., http://www.anothersite.com). And, instead of opening an HTML file, when clicked, an email link will open the user's email program (e.g., Microsoft Outlook)
Simply select a word or multiple words you want to convert to an email link and then:
<a href="mailto:yourname@yourcompany.com">Email Text goes here</a>
When creating a long document page, named anchors (bookmarks) can be used to "jump" or "auto-scroll" from the top of the page to links at the bottom of the page which eliminates the need for scrolling down the page manually. Conversely, a link can be placed at the bottom of the page and an anchor (normally called "top") can be used to "jump" back up to the top of the page. Named anchors can be used to jump WITHIN the SAME PAGE or at a LOCATION INSIDE another page.
CAUTION: You must used a LONG document when using named anchors. Otherwise, you will have to use alot of blank paragraph (e.g., <p> </p> to the bottom of the document to allow the page to scroll above the bottom fold of the user window.
Named anchors require TWO LINKS:
<a href="#A"> A </a> <a href="#B"> B </a> <a href="#C"> C </a> <a href="#D"> D </a>...
<a href="myfile.html#anchorname">Link text goes here</a>
Using an image map is like using an image link but with the ability to have MULTIPLE LINK options to choose from on a SINGLE image. If you have a SINGLE image with SEVERAL LINK AREAS (HOTSPOTS) that you want to use to take the user to different pages (or other interactivity), you can use an image maps.
The best thing to use image maps for is actually a geographic map where theres a lot of information and complicated shapes. Below is a list of reasons to avoid using them and is a reason why it is not included in the latest version of Dreamweaver.
What to use instead of an image map
It is best to use SVG instead of an image map in today's browser for several reasons. It is:
TIP: Use the following links to get free SVG maps:
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" xmlns:xlink="http://www.w3.org/1999/xlink" id="map" preserveAspectRatio="xMinYMin meet">
path id="Mississippi_State" class="st0" d="M594.5,168.5c0.6,0.7,1.3,1.5,2.3,1.6c-0.4,3.3-0.9,6.5-1.4,9.8c-0.5,3.3-0.9,6.6-1.4,10... /> </svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" xmlns:xlink="http://www.w3.org/1999/xlink" id="map" preserveAspectRatio="xMinYMin meet"><a xlink:href="#"> <path id="ab" fill="#D3D3D3" d="M351.371,342.397c-55 …" /> <a xlink:href="#"> <path id="Mississippi_State" class="st0" d="M594.5,168.5c0.6,0.7,1.3,1.5,2.3,1.6c-0.4,3.3-0.9,6.5-1.4,9.8c-0.5,3.3-0.9,6.6-1.4,10... /> </a> </svg>
<style>
path
{
transition: .6s fill;
fill:darkgreen;
}
path:hover
{
fill: lightgreen;
}
</style>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" xmlns:xlink="http://www.w3.org/1999/xlink" id="map" preserveAspectRatio="xMinYMin meet"><a xlink:href="#"> <path id="ab" fill="#D3D3D3" d="M351.371,342.397c-55 …" /> <a xlink:href="#"> <title>Mississippi</title> <path id="Mississippi_State" class="st0" d="M594.5,168.5c0.6,0.7,1.3,1.5,2.3,1.6c-0.4,3.3-0.9,6.5-1.4,9.8c-0.5,3.3-0.9,6.6-1.4,10... /> </a> </svg>
While most of the time we think of linking to a page, you can also link to a JavaScript function. There are three ways to do this.
EXAMPLE: Click To See Dialog
#1: Inline JavaScript.
#2: Internal JavaScript
<a href="javascript: HelloWorld()">Click To See Dialog</a>)
<script>
function HelloWorld()
{
alert('Hello, World');
}
</script>
#3: External JavaScript
<script type="text/javascript" src="HelloWorld.js"></script>
// JavaScript Document
function HelloWorld()
{
alert('Hello, World');
}