ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

How to Use Simple HTML Programming to Make a Link

Updated on May 12, 2013

HTML

Hyper Text Markup Language
Hyper Text Markup Language

What is HTML?

Hyper Text Markup Language or HTML as it is known to everyone is the main programming language used to create web pages and websites that are displayed on web browsers.

A markup language is a language that consists of a set of markup tags. These tags describe the content of the document.

HTML documents consists of these markup tags (HTML tags) and plain text. HTML documents (documents saved in the .html or .htm format) are known as webpages.

Sample HTML code: Copy-paste the following html code in Notepad and save it as test.html

<html>
<head>
<title>This is my First Webpage</title>
<h1>This is my heading</h1>
</head>
<body>
<p>This tag is used to format your text as a Paragraph</p>
<b>This tag makes your text bold</b>
<br> This tag takes you to the next line
<br><b> Congratulations on your First Successful Link</b>
</body>
</html>

What are HTML tags?

  • HTML tags are tag names enclosed in angle brackets(<>). Example: <html>
  • HTML tags usually consists of two pairs, the being known as the opening (or start) tag and the second, the closing (or end) tag. Example: <head> </head>
  • The end tag is exactly the same as the start tag except for a forward slash ( / ) before the tag name.

What is a Hyperlink?

A Hyperlink is basically any word, alphabet, group of words, text or even an image, used as a link that when clicked on re-directs you to a new webpage or document.

When your on a webpage if you move the cursor over a link, your cursor will turn from the arrow into a little hand with it's index pointing at the link. Place your cursor here to observe this.

HTML Link Syntax

<body>
<a href="url">Visible text which will be used as the link</a>
</body>

Basic and Simple HTML Link Syntax:

A Hyperlink or link in HTML is defined by the <a> tag, also known as an anchor tag.

An important attribute of the anchor tag ( <a> ) is href, which is a reference and indication (in simple words the address) of the link's destination.

The text that comes between the anchor tags( <a> text </a> ) is the anchor text, that is the link specified in the attribute href will get anchored to this text creating the link.

By default in all browsers links appear as follows:

  • An unvisited link is shown as underlined and blue in color.
  • A visited link (a link you have visited already previously) is underlined and purple in color.

  • An active link (a link that you have just clicked on) is underlined and red in color.

Simple Tutorial To Learn To Use Links In HTML:

  1. Open Notepad and copy paste the sample code provided above.
  2. Click Save.
  3. Name the file as Test.html and save it on your D drive (not in any folder, this will help in getting a simple URL address).
  4. Open a new Notepad file and copy paste the code given below.
  5. Save the file as Test2.html.
  6. You may save this file on your Desktop.
  7. You will now see your file Test2 on your Desktop with the Internet Explorer icon (or which ever is your default browser). This is because saving it as .html converts it into a Webpage.
  8. Double click and open Test2.
  9. You will know see the text "My First Link" in blue and underlined. Move your cursor over it and it'll turn into a little hand, showing you that it is a link.
  10. Click on it and it should re-direct you to your previous Webpage saved on your D drive, that is Test1.

Congratulations, you have just created your first HTML Webpages with links in them!

Sample Link Code: Copy-Paste the following html code and save it as Test2.html

<html>
<head>
<title>My Second Webpage</title>
</head>
<body>
<b>Let's create a Link</b>
<br>
<a href="D:\Test.html">My First Link</a>
</body>
</html>

Opening the HTML Linked Page in a New Window:

As you probably realized after trying out the above tutorial, that when you click on the link, the current page is closed and the next page opens in it's place.

In order to prevent this from happening, for instance when your putting a link to some other website within your website, you wouldn't want the other site to open up in place of yours. There are few chances of the user clicking on the back button and even if the user does so, it's annoying for him to keep going back and forward.

So a simple solution would be to open the link in a new window or tab.

The code given below is used to open the link in a new window:

target="_blank"

An example of how to implement this code is as follows..

You may substitute it for the previous link code in the tutorial file "Test2.html" and see how it works.

Syntax for Opening a HTML Link In a New Window :

<a href="D:\Test.html" target="_blank">My First Link</a>

Use An Image As A HTML Link:

We have seen above how to create links using text as an anchor..

We will now try and use an image as an anchor, that is, when you click on the image, it will re-direct you to the destination ( another website or webpage ) that you desire.

Syntax for Using An Image as a HTML Link:

<body>
<p>Click on the Image:
<a href="D:\Test.html"><img border="0" src="test.jpg" alt="Testing an image link" width="auto" height="auto"></a>
</p>
</body>

HTML Image Link Syntax Explaination:

In the above code, instead of putting text inside the anchor tags ( <a> </a> ), we have put the code to insert an image within the tags.

In the image insertion code, I have put the border as equal to 0, so has to leave your image without a border (if your image is a circle, it'll get a square border by default).

The width and height has been set to auto, so that it'll take the original width and height. (You can even remove the width and height from the code if you desire to do so)

Testing the HTML Image Link Code:

  1. Before testing the code, save an image on your desktop or where ever you have saved your Test2.html file.
  2. Rename the image as test.jpg.
  3. Now copy the syntax ( only the code between the body tags and not the body tags as well).
  4. Paste the code within the body tags of your Test2.html file.
  5. Save and open the file and check if it works.

© 2013 Paiva

working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://corp.maven.io/privacy-policy

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)