You are already aware that with HTML element <a>, we can link different HTML documents on a page.
For example, from this HTML document, we can add a link to Google.com by providing its URL in the
attribute.But HTML provides a technique through which we can link an HTML document's internal sections or elements.
Such links within a page are created with help of
attributes of HTML tags.Linking within the same document is helpful and creates a better user experience when a page is very long.
Let's create a link for a sub-section within the page.
First, we will define an HTML element with attribute
.The value of the
attribute will be a unique name.By unique, we mean that no other
will have the same name in that HTML document.This is like we have created a bookmark for William Shakespeare with the
william.Now we can create a link for the bookmark we created as follows:
Here we have written the
value after the (hash) symbol in the attribute.Below is a complete example. Click on 'Result on Editor' to view the output of the code.
From other HTML documents we can link to this bookmark as follows:
The
will be replaced with the actual URL of the document where the william is specified.If a page is very long and divided into different sections, providing links to such sections within a page is helpful to users.
It creates a better user experience because they can directly navigate to the sections they are more interested in.
On this page, we have talked about the HTML
attribute. Don't worry if you don't know about it. You will learn about it later in the tutorial.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 |