SimpleTuts.com

Insert hyperlinks in a webpage

Hyperlink

A hyperlink is a link from one document to another or to another location within the same document. It is created using the <a> (anchor) tag in HTML.

Anchor Tag (<a>)

The anchor tag is used to define a hyperlink. It is represented by the <a> element and requires an href attribute to specify the URL of the destination.

href Attribute

The href attribute specifies the URL of the page the link goes to. Without the href attribute, the <a> tag will not create a link.

target="_blank"

The target attribute specifies where to open the linked document. The value _blank opens the linked document in a new window or tab.

Step 1

Open the code editor 'Notepad++' and add the following code


<html>
<head>
	<title>Hyperlinks in a webpage</title>
</head>
<body>
	<!-- Normal Link -->
	<a href="insert-images.html">Visit My Gallery</a>
	
	<br><br>
	
	<!-- Open in new tab -->
	<a href="more-tags.html" target="_blank" >Basic HTML Tags</a>
	
	<br><br>
	
	<!-- Link to live website -->
	<a href="http://www.amazon.com">Shop Now</a>
	
	<br><br>
	
	<!-- Link for an image -->
	<a href="http://www.nature.com/">
		<img src="nature1.webp" width="300">
	</a>
</body>
</html>
Run Code

Then save the file in your folder

Step 2

Go to the file location and open the file in your browser

Watch video