Author: Michal Szymanski
HTML Links - Hyperlinks
HTML links are hyperlinks.
You can click on a link and jump to another document.
When you move the mouse over a link, the mouse arrow will turn into a little hand.
Note: A link does not have to be text. It can be an image or any other HTML element.
In HTML, links are defined with the
<a href="url">link text</a>
<a href="https://mdbootstrap.com/">Visit our HomePage</a>
href attribute specifies the destination address
of the link.
The link text is the visible part (Visit our HomePage).
Clicking on the link text will send you to the specified address.
The example above used an absolute URL (a full web address).
A local link (link to the same web site) is specified with a relative URL (without https://www....).
<a href="images/photo-1.jpg">Link to the image</a>
The target Attribute
target attribute specifies where to open the linked document.
The target attribute can have one of the following values:
- _blank - Opens the linked document in a new window or tab
- _self - Opens the linked document in the same window/tab as it was clicked (this is default)
- _parent - Opens the linked document in the parent frame
- _top - Opens the linked document in the full body of the window
- framename - Opens the linked document in a named frame
This example will open the linked document in a new browser window/tab:
<a href="https://mdbootstrap.com/" target="_blank">Visit MDBootstrap</a>
Image as Link
It is common to use images as links:
<a href="https://mdbootstrap.com/" target="_blank"><img src="https://mdbootstrap.com/img/logo/mdb192x192.jpg"></a>
Live preview (click the image)
Create a Bookmark
HTML bookmarks are used to allow readers to jump to specific parts of a Web page.
Bookmarks can be useful if your webpage is very long.
To make a bookmark, you must first create the bookmark, and then add a link to it.
When the link is clicked, the page will scroll to the location with the bookmark.
First, create a bookmark with the
<h2 id="C4">Chapter 4</h2>
Then, add a link to the bookmark ("Jump to Chapter 4"), from within the same page:
<a href="#C4">Jump to Chapter 4</a>
Previous lesson Next lesson
Spread the word: