Link Tag

Links are created using the element. Users can click on anything between the opening tag and the closing tag. You specify which page you want to link to using the href attribute

link tag-html

The text between the opening tag and closing tag is known as link text. Where possible, your link text should explain where visitors will be taken if they click on it (rather than just saying “click here”). Below you can see the link to IMDB that was created above.

To write good link text, you can think of words people might use when searching for the page that you are linking to. (For example, rather than write “places to stay” you could use something more specific such as “hotels in New York.”)

Linking To Other Websites

Links are created using the element which has an attribute called href. The value of the href attribute is the page that you want people to go to when they click on the link. Users can click on anything that appears between the opening tag and the closing tag and will be taken to the page specified in the href attribute. When you link to a different website, the value of the href attribute will be the full web address for the site, which is known as an absolute URL

EXAMPLE

<a href=”https://www.w3schools.com/”>W3SCHOOL</a>

OUTPUT

Linking To Other Pages On The Same Site

When you are linking to other pages within the same site, you do not need to specify the domain name in the URL. You can use a shorthand known as a relative URL. If all the pages of the site are in the same folder, then the value of the href attribute is just the name of the file. If you have different pages of a site in different folders, then you can use a slightly more complex syntax to indicate where the page is in relation to the current page

EXAMPLE

< href=”https://www.codingknack.com/”>Codingknack</a>

OUTPUT

Email Links

To create a link that starts up the user’s email program and addresses an email to a specified email address, you use the element. However, this time the value of the href attribute starts with mailto: and is followed by the email address you want the email to be sent to. On the right you can see that an email link looks just like any other link but, when it is clicked on, the user’s email program will open a new email message and address it to the person specified in the link.

EXAMPLE

<a href=”mail to : noman@example.org”Email noman</a>

OUTPUT

Differences Between HTML and XHTML

In HTML the <link> tag has no end tag.

In XHTML the <link> tag must be properly closed.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu