In the last article we learned about:Now in this post, we are going to see HTML links in detail.
- Comments in Html.
We know that we can use links in HTML to navigate from one page to another. When we hover over element containing a link, it generally changes to blue and mouse changes to hand icon in the browser. We all have seen examples of links in previous posts where we used following things:
- Enclosing text to be used as link in and tags
- Giving href Attribute in tag and setting its value to the desired link
To do this, first we will create a image in HTML using tag and then we will enclose it within and tags with href attribute.
Also, we can create bookmarks in the Document so that users can directly go to the specified part in the large document much like you see in Wikipedia. So let's see how to create it.
First, let's create a paragraph and give it attribute id and set it's value to say para5. Now create another element with text like Link to Paragraph 5 and enclose it within and tags while giving it href attribute with value #para5. In short, we will give attribute same as id to paragraph but including # symbol to tell HTML that text following it indicates id. You will clearly see it's effect only when your document is large so that your page will scroll down to that particular element.
That is more than sufficient knowledge regarding links, but as we are learning I am also adding one more thing here, target attribute in links.
We can add the target attribute to link element to control where to open the linked page or document.
Value of target Use
- _blank Open the document/ link in new window or tab
- _self Open the document/ link in same window or tab
- _top Opens the document in the full body of the window
- _parent Opens the document in parent window
That's all for this article.In the next part, we will learn more about images and will also start tables in HTML. Comment on how you think this article is, what improvements should I do and for any doubts. Share with your friends and keep coding.