WDS9 - More about HTML Links
Tags: html, wds, webdev
Published: 2017-12-14 16:38:32

---
title: "WDS9 - More about HTML Links"
published: true
tags: HTML,WDS, webDev
canonical_url: http://thecodingexpress.blogspot.com/2017/12/wds9-more-about-html-links.html
---

In the [last article](http://thecodingexpress.blogspot.in/2017/12/wds8-use-of-quotes-and-comments.html) we learned about:  

- Quotations
- Comments in HTML.

Now in this post, we are going to see HTML links in detail.  
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 **\<a\>** and **\</a\>** tags
- Giving href attribute in **\<a\>** tag and setting its value to the desired link
In all the examples we used the text links to other webpages that are sites like google.com or say, facebook.com, but it is interesting to know that you can enclose other HTML elements such as images inside link tags to use images as the link to other pages.  
To do this, first we will create a image in HTML using **\<img\>** tag and then we will enclose it within **\<a\>** and **\</a\>** tags with href attribute.  
 <script async="" src="//jsfiddle.net/TheCodingExpress/f2zejgpo/embed/html,result/dark/"></script>   
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 **\<a\>** and **\</a\>** 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.  
 <script async="" src="//jsfiddle.net/TheCodingExpress/fdvm4xpw/embed/html,result/dark/"></script>   
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.  
  
**&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Value of target &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Use**   

1. **\_blank&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;** Open the document/ link in new window or tab
2. **\_self&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;** Open the document/ link in same window or tab
3. **\_top&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;** Opens the document in the full body of the window
4. **\_parent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;** 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** _.