The href=”tel:” Attribute
While coding in HTML, all that is required to make a phone number link is adding the anchor tag with a href=”tel:” attribute containing the phone number to be dialed on clicking the link.
Example: Adding Mobile Number Link Through HTML
Following is a random example of a phone number link added in the <a> tag:
In the above code snippet, there is a <h2> heading. This is optional and is added just to make sense of the added phone number in the output interface.
- After that, there is the <a> tag that contains the main operation to be performed here.
- Inside the <a> opening tag, there is the href=”tel:” attribute that contains the phone number that is supposed to be dialed when the link is clicked.
- Between the starting and closing anchor tags is the link that will be displayed in the output interface. This will basically be the content to be displayed on the output graphical interface in the form of a clickable link. It can be any name or text or the same number added in the opening tag.
When the user clicks on the link, it will automatically dial the number and the output interface will be as following:
This sums up the use of href=”tel:” attribute in creating mobile number links on a web page.
Conclusion
Contact number links let the users directly call without needing to dial the phone number separating and can be created using the href=”tel:” attribute inside the opening anchor tag with the contact number. Between the opening and closing <a> tags should be content to be displayed on the graphical interface in the form of a clickable link, clicking on which dials the number automatically.