The HTML provides an element <a> through which we can create a link between the different documents and navigate.
It is also called an HTML hyperlink, and it is not just capable of linking external documents, but also, the section of a web page can be linked, which we will learn later in the tutorial in the chapter HTML Bookmarks.
Let's see the syntax for creating a link for an HTML document:
For example, suppose we want to send a user to visit our first chapter 'Introduction to HTML'. Now we know that the name of that HTML document is 'what-is-html' (URL). Then we will create a link as follows:
The link will be displayed on the page in the browser as:
Let's take another example where we want to create a link for our website homepage. Then we will create a link in an HTML document as follows:
The browser will display it as follows:
Let's take an example. Click on the 'Result on Editor' button to examine the output on the web browser screen.
Here we notice that only the content of the element <a> is visible on the screen and the URL part is hidden.
For example, the text Home Page is displayed on the web screen.
We also notice that when we move the mouse pointer over a link, it turns into a little hand and when we click it, the browser opens the page whose URL was specified in theattribute.
So, basically, HTML links are the mechanism through which we can create an interconnection between the different HTML documents.
The href attribute of element <a> contains the address of the page (URL) that we want to link to.
This address can either be specified with an absolute URL or a relative URL.
An absolute URL is a full web address which means it contains the protocol, hostname, and path to a specific resource on the internet.
A relative URL only contains the path to the document and is relative to the current page.
Note: A relative URL that starts with a slashis relative to the root domain while a relative URL that starts without a slash is relative to the current page.
For example, if we are viewing a page at https://resultuniversity.com/html/what-is-html then a relative URL basic-html-tags resolves to:
And a relative URL /css/what-is-css resolves to:
While browsing the internet you have come across links that open in new windows or tabs when clicked. This functionality is achieved using the <a>.attribute of element
It specifies where to open a linked resource (URL).
The target attribute can have the following values:
The tag <a> can be specified with a attribute. The value of the attribute is shown as tooltip text when the user mouse over the defined link.
It is used to provide extra information about the link user going to click.
HTML can create links for emails. All we need to do is to write the email address after <a>.in the attribute of tag
See the example below:
The element <a> can be nested and it can contain other elements inside.
Hence it is not just text that can be made into a link but also other elements of HTML can be made into links.
An <img> element inside the opening <a> and the closing </a> tags make an image link.
When an <button> element is defined inside the start tag <a> and the end tag </a>, the button element turns into a button link.
|1. HTML Tutorial|
|2. Introduction to HTML|
|3. Basic HTML Page|
|4. HTML Editors|
|5. Web Browser|
|6. HTML History|
|7. Basic HTML Tags|
|8. HTML Elements|
|9. HTML Attributes|
|10. HTML Headings|
|11. HTML Paragraphs|
|12. HTML Text Formatting|
|13. HTML Styles|
|14. HTML Comment|
|15. HTML Quotation|
|16. HTML Colors|
|17. HTML RGB Colors|
|18. HTML HEX Colors|
|19. HTML HSL Color|
|20. HTML CSS|
|21. HTML Links|
|22. HTML Link Colors|
|23. Link within Page|
|24. HTML Images|
|25. HTML Background Image|
|26. HTML Image Map|
|27. HTML Picture Element|
|28. HTML Favicon|
|29. HTML Table|
|30. HTML Table Border|
|31. HTML Table Size|