How to create button to open SMS compose to a phone number using HTML ?

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:
Before clicking the link:

After clicking the link:



For Multiple Recipient:
Syntax:

<a href="sms:(countrycode)(number), 
    (countrycode)(number), ...."> Text </a>

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:
Before clicking the link:

After clicking the link:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.