Creating Links in HTML

It is basic that if you’re creating a web,it is definite that you’ll want it to point to other web pages and resources, whether on your own site or someone else’s.In this page we’ll look at the markup that makes links work: to other sites, to your own site, and within a page. There is one element that makes linking possible: the anchor (a) .To make a selection of text a link, simply wrap it in opening and closing   <a>  ...  </a>   tags and use the href attribute to provide the URL of the target page. The content of the anchor element becomes the hypertext link.

Examples of linking

<a href=" URL  "about < /a>

Explaination of links

In the above given source code the "href" is an attribute which holds the targeted url.Through this attribute we will direct to some target.If href attribute is not present in between the "a" (anchor tag), than "a" will not be a hyperlink. Please don't leave the "href" attribute empty, because the empty "href" attribute will be considered as broken link which put negative impact on you SEO scores.


Link through image

<a href="html-14.php"><img src="img/core-img/favicon.ico" alt="favicon"> < /a>

Click on this image. favicon

Explaination of image linking

To make an image a link, simply put the img element in the anchor element. Sometime on some social sites or anywhere you see some logo,when you click on that they redirect you to some targeted post.Actually they are link on the back of image.They are very important and very used in html.


The href Attribute

The href hypertext reference attribute is used to provides the address of the page or resource (its URL) which you want to the browser. The given URL must be always appear in quotation marks.Most of the time you’ll point to other HTML documents; however, you can also point to other web resources, such as images, audio, and video files.Because there’s not much to slapping anchor tags around some content, the real trick to linking comes in getting the URL correct.

. Absolute URLs

Absolute URLs is used to provide the full URL for the document, including the protocol (http://), the domain name, and the pathname as necessary.You need to use an absolute URL when pointing to a document out on the Web (i.e., not on your own server).
Example: href="https://www.webtags.com.pk/"

.Relative URLs

Relative URLs is used describe the pathname to a file relative to the current document. Relative URLs can be used when you are linking to another document on your own site (i.e., on the same server). It doesn’t require the protocol or domain name—just the pathname.
Example: href="xyz/index.html"








The Best

Comment here

If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.


ads