With so many people accessing the Internet via smartphones it makes sense to style telephone numbers on web pages as links that can be clicked to make a normal voice call. Remember that this will only work on a device capable of making a telephone call.

In this post:
  1. Basic
  2. Disable
  3. CSS
Required knowledge:

1. Basic

The basic telephone link looks similar to the standard anchor tag, with the difference being the protocol in the value for the href attribute:

<a href="tel:+16505434800">+1 (650) 543 4800</a>

tel: is as much a protocol as for example http: or ftp:.

2. Disable

iOS autodetects telephone numbers, but as the web developer you can switch that off if you want to with the following meta tag:

<meta name="format-detection" content="telephone=no">

To prevent search engines from trying to index telephone links (follow the link to see where it goes), use the rel attribute with the value nofollow:

<a href="tel:+01-562-867-5309" rel="nofollow">1-562-867-5309</a>

3. CSS

The following cool CSS from the link below:

Let’s say we only styles to apply to telephone links. We can do that with a pseudo selector that searches out the tel: text in a given URL:

a[href^="tel:"] {
  color: orange;
  text-decoration: none;
}

Example: +27844233359

Tuts+ has a nice trick using the ::before pseudo selector to add the Unicode phone character before the number is displayed:

a[href^="tel:"]:before {
  content: "\260e";
  margin-right: 0.5em;
}

Example: +27844233359


References:

  1. The Current State of Telephone Links | CSS-Tricks. (2016). Retrieved 4 November 2022, from https://css-tricks.com/the-current-state-of-telephone-links/

By MisterFoxOnline

Mister Fox AKA @MisterFoxOnline is an ICT, IT and CAT Teacher. He has a passion for technology and loves to find solutions to problems using the skills he has learned in the course of his IT career.

Leave a Reply

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