Ads by ProfitSence
Close

HTML Links

Last Updated on Wednesday 5th Oct 2022

html hyperlink

HTML Links - Hyperlinks

Hyperlinks are one of the most exciting innovations the Web has to offer. It allow us to link documents to other documents or resources, link to specific parts of documents, or make apps available at a web address.

We can create links in HTML if we use anchor elements. The anchor tags are these <a> and </a> tags. A link does not have to be text. A link can be an image or any other HTML element.

hyperlink html

Syntax

			
					<a href="url">Some Text</a>

			
	

The following about one attribute that will tell the browser how to open the link we have clicked. This attribute name is called target.

			
					<a href="url" target="_blank">With Target Attribute</a>

			
	

The target attribute will tell the browser where to open the linked document.

  • _blank - It will tell the browser to open the link in a new window or tab.
  • _self – It will open the linked document in the same frame as it was clicked or this is the default action of the anchor tag.
  • _top – It will open the linked document in the full body of the window
  • _parent – It will open the linked document in the parent frame

hyperlinks html

Link to an Email Address

Use mailto: inside the href attribute to create a link that opens the user's email program.

			
					<a href="mailto:contact@codejagd.com">Send email</a>

			
	

Use an Image as a Link

To use an image as a link, just put the <img> tag inside the <a> tag.

			
					<a href="url">
  <img src="/2.png" alt="CJ" />
</a>

			
	

Download an Image

If we want to download a file from a server using the anchor tag.We have attribute called download and it does not require a value.

			
					<a href="2.png" download>Download</a>

			
	

Absolute URLs and Relative URLs

  • Absolute URLs - A link with https://www part
  • Relative URLs - A local link (a link to a page within the same website) is specified with a relative URL
			
					<a href="https://codejagd.com/html-links">HTML Links</a>

			
	
  • https:// - Protocol
  • codejagd.com - Site Name
  • html-links - File Name
			
					<a href="/html-links">HTML Links</a>

			
	
hyperlink in html
hyperlinks in html
hyperlink
html link code
html code for link
add a link html
add a link in html
add link html
add link in html
adding links html
adding a link html
hypertext in html
hypertext html
a link in html
link to html
linking in html
links in html
links on html
a tag of html