Sometimes, when you search for a number on the web, you might want to SMS to it directly from the web page instead of noting it down and then messaging to it. It becomes quite convenient for the user. Making an SMS link is very easy in HTML. Here, we will see how to make the SMS link on a webpage.
Approach: Using <a> href attribute: Enter the phone number in place of the URL and add sms: before it to make an SMS link. Add the text between the tags that will appear as the clickable link.
For Single Recipient:
Syntax:
<a href="sms:(countrycode)(number)"> Text </a>
Example:
<!DOCTYPE html>
< html >
< head >
< title >
Create button to open SMS
compose to a phone number
</ title >
</ head >
< body >
< p >
For any queries you can text
us at the below number:
</ p >
< a href = "sms:+911234567890" >
+91-123-4567-890
</ a >
</ body >
</ html >
|
Output:
Before clicking the link:

After clicking the link:

For Multiple Recipient:
Syntax:
<a href="sms:(countrycode)(number),
(countrycode)(number), ...."> Text </a>
Example:
<!DOCTYPE html>
< html >
< head >
< title >
Create button to open SMS
compose to a phone number
</ title >
</ head >
< body >
< p >
Send text to multiple
recipients:
</ p >
< a href="sms:+911234567890,
+11234567890">
Send a SMS
</ a >
</ body >
</ html >
|
Output:
Before clicking the link:

After clicking the link:
