HTML Linking Basics – Engineering Technology Services (2024)

Overview

All links on a page will have a distinctive appearance unless it is overridden by the browser or by using Cascading Style Sheets (CSS). There will be an underline beneath the text of the link and it will usually be blue in color. It is also possible to place the <a> tag around an image tag to make that image a link.

<a>

A link (or hyperlink as it is also called) is created with a special <a> tag called an "anchor". It requires a closing tag and is used to delineate the text or HTML content that should be linked on the page. An <a> tag can also be used to mark a section of a web page as a target for another link to jump to. For example, this link will jump to the bottom of this page. If the "name" and "id" attribute is used, the <a> tag is an anchor, but if the "href" attribute is used then it is a link. Both attributes can be used simultaneously.

  • Attributes for the <a> tag:
    • href - This is the most used attribute for the <a> tag. This is what is used to create a hyperlink. The value associated with the href attribute should be either a complete or relative address to another web page, a mail link or an anchor name (prefaced with the "#" symbol). See below for more information on how to create these values for your links.
    • name - This attribute creates an anchor on your page that another <a> tag can link to. In essence, the use of the name attribute means that you must use two <a> tags; one as the anchor using the name attribute and one as the link to the anchor using the href attribute. To link to an anchor in this way, the href attribute must be set to the name of the anchor prefaced by a "#" or pound sign. For example: <a href="#bottom">Link to the bottom of the page</a> And the anchor tag could look like this: <a name="bottom" id="bottom">This is the anchor text</a> This attribute is depreciated in the latest version of the web standards in favor of the "id" attribute.
    • id - The creates a unique identifier that distinguishes the <a> tag from every other element on the web page. Since the name attribute is slowly being phased out in the latest browsers, it is best to use both the name and the id attributes together when you create a anchor on your page so that you will be safe with both old and new browsers. Make sure that both attributes have the same value. An example of this is shown above in the "name" attribute information.
    • target - This attribute defines where the new web page will be loaded into when the link is clicked on. The options are "_blank", "_parent", "_self", "_top" and a frame's name. The default is "_self". Unless you are using frames (which you shouldn't), the only reason to use the target attribute is with the _blank option.
      • _blank - This will cause the link to always open a new browser window. This is useful if you are linking to another site entirely but still want your site to be accessible on the person's computer. Many people find this to be annoying, so use it sparingly.
      • _parent - Only used with frames, otherwise it acts like "_self"
      • code - This is the normal function of a link. The new page will load in the same window as the original page.
      • _top - This ensures that the new page loads in the full screen of the window. Mainly used to "break out" of frames. Otherwise it acts like "_self"
      • A frame's name - If you are using frames with your site (they should be used rarely, if at all) then you can enter the frame's name so that the resulting page you are linking to will appear in the appropriate frame window.
  • Example: <a href="somewhere.html" name="linktome" id="linktome" target="_blank">Go Somewhere</a> This tag will create both a link and an anchor. The link will go to the page "somewhere.html" and the anchor is named "linktome". The target attribute causes the link to open in a new browser window.

Send an email with a link

Besides linking to another web page or within another location on a page, you can also create a link to an email address. Depending on the browser’s ability, the operating system and the software installed, this will cause the viewer’s email program to automatically load and the email address will be placed in the “send to” field of the new email window.

To do this, type the email address as the value for the "href" attribute and precede it with "mailto:" For example: <a href="mailto:joesmith@somewhere.com">Email Joe</a> There is an unfortunate side effect with doing this, however. There are programs created by "spammers" that scan web pages looking for email addresses within a web page. If it finds one, that email address is added to the spammer's database and that address will begin to be filled with junk. There are ways around this, fortunately. If you are interested, send a message to ETS to learn more.

Relative and absolute links

When you create a link by adding a value to the "href" attribute of an <a> tag, you must be careful that the value will not create a "broken" link, or a link that is not valid. This is a very easy thing to do, especially if you rely on an HTML editor to make these links for you. It is very common that an HTML editor will create a link that points to a location on the computer you are working with instead of the correct location on the web server.

There are two ways to create a link; relative and absolute. An absolute link defines the location of the page completely. For example: <a href="http://www.engr.colostate.edu/ETS/index.html"> This is an absolute link because it includes everything needed to find the location including the protocol, server, directory and file name. Absolute links are easy to use and you rarely have trouble with them. This method must be used if your link points to a location that is not within the web server your pages are on.

On the other hand, relative links take advantage of the fact that the browser already knows where the current document is. And so all that is needed is the relation between the current document and the location of the link. For example: <a href="page.html"> is relative because only the file name is given. The browser knows the location of the current document and so assumes that the file "page.html" is in the same directory as the current document. What if the file you are linking to is not in the same directory? Then you will need to provide either the path to a sub-directory by including the directory's names or use "../" to go "up" a directory from the one you are in. This table may shed some light on this concept:

The Path What it means
<a href="page.html"> The file "page.html" is located in the current directory.
<a href="tips/page.html> The file "page.html" is located in a directory called "tips" that is located in the current directory.
<a href="tips/other/page.html> The file "page.html" is located in a directory called "other" that is located in a directory called "tips" that is located in the current directory.
<a href="../page.html"> The file "page.html" is located in a directory that is one level up from the current page. Using the example immediately above, if the current directory was "other", then this path would go one step up to the "tips" directory to find the "page.html" file.
<a href="../../page.html"> The file "page.html" is located in a directory two levels up from the current directory.
<a href="/page.html"> The file "page.html" is located in the "root" of the web server. Notice the slash before the name. This means that the browser will go all the way down to the most basic or "root" level of the web server to find the file. For example: if the current file is located at "http://www.engr.colostate.edu/ets/how/web/links.html" then this link would go to "http://www.engr.colostate.edu/page.html"

These methods could be used together to find a specific file within your web directory structure. For example: <a href="../../prefs/location/index.html"> would go up two directories and then back down two directories named "prefs" and "location" to find the "index.html" web file.

Web directory locations

A common problem with creating a link using an HTML editor is that your links will work just fine when your web file is on your computer, but when you place the files on the web server, the links all break. This is because your editor is pointing the link to a location on your computer and not the correct location as it should be on the server as illustrated above.

There are a number of locations on the Engineering network that have been set aside for serving web pages via the Internet. These locations are basically directories on the network that have been configured as a location to “serve” web pages via the Internet. The main thing to remember concerning this is that any directory or file that is “up” from the web directory is invisible to the Internet. Or in other words, the only files visible on the Internet are within a web directory that has been created to serve web pages, and any sub-directories it contains. And so any link to a location that is not within that directory will not work. The browser will tell you that the link could not be found.

For example: all faculty, staff and students in the Engineering College have access to a “public_html” directory that has been set aside to serve web pages from within your U:\ drive. So all files placed within the public_html directory can be viewed via the Internet. But any file within your U:\ drive that is not within your public_html directory can not be seen or linked to via the web.

*This line of text is the anchor for the link at the top of the page. This link will jump back to the top again.

HTML Linking Basics – Engineering Technology Services (2024)

FAQs

What is linking in HTML in web technology? ›

Chapter Summary
  1. Use the <a> element to define a link.
  2. Use the href attribute to define the link address.
  3. Use the target attribute to define where to open the linked document.
  4. Use the <img> element (inside <a> ) to use an image as a link.

How do you pass a link in HTML? ›

HTML <a> Tag – Anchor Link HREF Example. You can use HTML's <a> tag to link to different parts of a website, to another web page, or to a separate website entirely. By default, it is underlined and given a bluish color, but you can override these style defaults with CSS (which a lot of people do).

How do I link an HTML file to another HTML file? ›

To link an HTML file to another HTML file, you can use the <a> tag. The <a> tag is used to create a hyperlink to another web page or a different location within the same page. To create a link to another HTML file, you would use the href attribute of the <a> tag.

How to link two HTML files together? ›

A link (or hyperlink as it is also called) is created with a special <a> tag called an "anchor". It requires a closing tag and is used to delineate the text or HTML content that should be linked on the page. An <a> tag can also be used to mark a section of a web page as a target for another link to jump to.

What are the three types of links in HTML? ›

To make a hyperlink in HTML, use the anchor tag: <a href="URL" title="Description of link">link text</a> . There are three different types of hyperlinks on the web, absolute, relative, and inline links.

How do you link HTML? ›

The <a> tag defines a hyperlink, which is used to link from one page to another. The most important attribute of the <a> element is the href attribute, which indicates the link's destination. By default, links will appear as follows in all browsers: An unvisited link is underlined and blue.

How do you link to another page on your website in HTML? ›

Linking in HTML code is done with the anchor tag, the <A> tag. The letter "A" in the tag is then followed by an attribute. For a link to another web page, the "A" is followed by "HREF". To set a bookmark in the same page, the "A" is followed by "NAME", which you'll see how to do later.

How do I link an HTML button to another HTML file? ›

Using Button Tag Inside <a> tag

The \<a> tag defines a hyperlink and is usually used to link a page to another. The most important attribute of the tag is href which indicates the link's destination. We will implement all the buttons inside the FirstPage. html using \<a> tag.

How to link an HTML page to another HTML page in the same folder? ›

html in your directories, you can make links to these pages by just linking to the directory name. Your browser will always pick up index as the main page for that folder. This means you can condense href="folder/index. html" into href="folder/" .

What type of coding is used to create links? ›

The HTML a tag is used to create hyperlinks and specify the URL that the link points to.

Which of the following is used to read an HTML page and render it? ›

The correct answer to “HTML Web Pages Can Be Read And Rendered By?” is “Web browsers.”

Where are HTML pages stored on the internet? ›

The web page is stored on a computer known as a web server (server, for short). In order for the web page to be displayed on that computer or another computer, it must be accessed and interpreted by a specially designed program called the client software (client, for short).

What is linking to a website? ›

Types of links

Internal link. A link between two webpages, where both webpages belong to the same website, is called an internal link. Without internal links, there's no such thing as a website (unless, of course, it's a one-page website). External link. A link from your webpage to someone else's webpage.

What does mean in HTML link? ›

A hash - `#` within a hyperlink specifies an HTML element id to which the window should be scrolled. href="#some-id" would scroll to an element on the current page such as <div id="some-id"> . href="//site. example/#some-id" would go to site. example and scroll to the id on that page.

What are the benefits of linking in HTML? ›

Uses Of HTML Link Tag
  • Improve Navigation: Links help users easily navigate between pages and sections of a website.
  • SEO Consideration: Search engines like Google use links to discover new pages on websites.
Sep 4, 2024

Why is a used for links in HTML? ›

The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address. Content within each <a> should indicate the link's destination.

Top Articles
2 Growing Dividends To Buy On The Coming September Dip
6 Top Real Estate Investment Strategies with Little Money or No Money
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Greg Kuvalis

Last Updated:

Views: 6495

Rating: 4.4 / 5 (55 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Greg Kuvalis

Birthday: 1996-12-20

Address: 53157 Trantow Inlet, Townemouth, FL 92564-0267

Phone: +68218650356656

Job: IT Representative

Hobby: Knitting, Amateur radio, Skiing, Running, Mountain biking, Slacklining, Electronics

Introduction: My name is Greg Kuvalis, I am a witty, spotless, beautiful, charming, delightful, thankful, beautiful person who loves writing and wants to share my knowledge and understanding with you.