Monday, 25 September 2023

Hyperlinks in HTML

    Using Multimedia in HTML..?


What are Hyperlinks..?

  • HTML links are hyperlinks.
  • We can click on a link and go to another document or web page.
  • Hyperlinks form the basis of the web.


Hyperlinks are defined using the <a> tag. The <a> tag has two attributes. The first attribute of the <a> tag is the href attribute, which indicates the link's destination. The second attribute is the link text. It’s the part that will be visible to the user of the website. By clicking on the link text, the user will be sent to the specified URL address.

By default, the linked page will be displayed in the current browser window. To change this, we must specify the target attribute for the link. The target attribute specifies where to open the linked document.


Open a Link in a New Tab

By default the browser opens links in the same tab. When a link points to an external site, it is good practice to make it open in a separate tab. We don't want to lose our site's visitors. 


To accomplish that we can use the target attribute  to the opening <a> tag, and give it the value _blank which opens links in a new tab.


Syntax :-

<a href= "https://open.uom.lk/" target="_blank"> Home Page </a>



Sending an Email

Using hyperlinks we can intergrade email feature. 


We can use the following syntax. 


Syntax :-

<a href="mailto:email address">Send Email !</a>


In here the href attribute starts with mailto: and then the email address you want to send a message to. 


The link by default doesn't look any different than the other links we' discussed during the lecture. But when it's clicked on, it automatically starts to compose a new email with the user's default emailing software.


It will automatically fill the "To" filed with the email address as well. 

Code :-

Output:-



Written by:  W.A. Eranga Dewmini

No comments:

Post a Comment

Java Script Learning

 Introduction to JavaScript JavaScript is the programming language used by front-end web developers to instruct the browser to add behaviors...