Code Skiller logoCB Logo
Logo LearnLearnLogo PracticePracticeLogo HireHireLogo IDEIDE

HTML Links

User image

Published by

sanya sanya

Published at: 4th Aug, 2023
1.815 mins read

A link is basically a connection from one source to another. It has two ends, firstly the source where the link exists and secondly the 'destination' where the link when clicked redirects the user, which may be any web resource such as an HTML document, an element (section) within an HTML document, an image, a video clip or an audio file, etc.

To add a link, we need to use a simple element - <a> - "a" being the short form for "anchor".

  • Choose the text which you want to convert into a Link.

  • Wrap the text in an <a> element, as shown below:

example: <a> This is a Link</a>

  • Give the <a> element an href attribute :-

example: <a href=" "> This is a Link </a>

  • Fill in the value of this attribute with the web address that you want the link to:

example: <a href="http://www.codingblocks.com"> This is a Link </a>


Attributes

href

The href attribute is used to specify the destination address of the link used. "href" stands for Hypertext reference. Text link: The text link is the visible part of the link. It is what the viewer clicks on.

  • Telephone numbers with tel: URLs
  • Email addresses with mailto: URLs

Target

Where to display the linked URL, The following keywords have special meanings for where to load the URL:

  • _self: the current browsing context. (Default)
  • _blank: usually a new tab, but users can configure browsers to open a new window instead.
  • _parent: the parent browsing context of the current one. If no parent, behaves as _self.
  • _top: the topmost browsing context (the "highest" context that's an ancestor of the current one). If no ancestors, behaves as _self.


Here is an example of how we can create links in HTML, we can also link paragraphs with IDs given to them (eg:- "special") on the same page as well as on the other page. Clicking on the link will redirect the user to that content!

Library

WEB DEVELOPMENT

Basic

HTML - Hyper Text Markup Language

HTML: Hyper Text Markup Language

Getting Started with HTML

Working with Tags

HTML Tags

Attributes

Block & Inline Elements , HTML Entities

HTML Links

HTML Forms

Tables In HTML

HTML SEMANTICS

CSS - Cascading Style Sheets

JavaScript

Frontend

Backend

Interview Questions

FAANG QUESTIONS

On this page

Attributes

href

Target