HTML5 Input Type Tel

The tel input type is intended for telephone number inputs. While it does not validate the format of the telephone number entered, it prompts mobile browsers to display a telephone keypad, making it easier for users to enter phone numbers.

Features:

  • Optimizes mobile keyboard for telephone number input.
  • Does not enforce a specific format, offering global compatibility.
  • Can be used in conjunction with pattern attributes for custom validation.

Example:

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
        "width=device-width, initial-scale=1.0">
    <title>HTML5 Input Type Tel</title>
</head>
  
<body>
    <form>
        <label for="phone">Phone Number:</label>
  
        <input type="tel" id="phone" name="phone" 
            pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}" 
            placeholder="123-456-7890">
      
        <input type="submit">
    </form>
</body>
  
</html>


Output

Difference Between Input Type number and tel in HTML

In HTML5, form inputs have been significantly enhanced to facilitate more specific data types and improve user experience across various devices. Among these enhancements, the number and tel input types are notable for their specific purposes. Understanding the distinction between these two types is crucial for web developers aiming to create intuitive and efficient web forms. This article provides a detailed overview of both input types, complete with descriptions, code examples, and a comparative analysis.

Similar Reads

HTML5 Input Type Number

The number input type is designed for numerical input, allowing users to enter a floating point number. It is particularly useful for quantities, prices, and other number-based inputs. This input type offers built-in validation for numerical data and enables browsers to display number-specific controls, like spinners to increase or decrease the value....

HTML5 Input Type Tel

...

Difference between Number vs Tel Input Type

The tel input type is intended for telephone number inputs. While it does not validate the format of the telephone number entered, it prompts mobile browsers to display a telephone keypad, making it easier for users to enter phone numbers....