Open In App

HTML DOM Input Email size Property

Improve
Improve
Like Article
Like
Save
Share
Report

The Input Email size property in HTML DOM is used to set or return the value of the size attribute of an Input Email Field. The size attribute is used to define the width of an email field. Its default value is 20.

Syntax:

  • It returns the Input Email size property.
    emailObject.size
  • It is used to set the Input Email size property.
    emailObject.size = number

Property Value: It contains single value number which is used to specify the width of an email field in terms of the number of characters.

Return Value: It returns the numeric value which represents the width of an email field in terms of number of characters.

Example 1: This example illustrates how to return Input Email size property.

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Input Email size Property
    </title>
</head>
 
<body style="text-align:center;">
 
    <h1>GeeksforGeeks</h1>
 
    <h2>HTML DOM Input Email size Property</h2>
 
    <label>E-mail:</label>
    <input type="email" id="email"
        name="myGeeks" size="10">
 
    <br><br>
 
    <button onclick="myGeeks()">
        Click Here!
    </button>
 
    <p id="result"></p>
 
    <!-- Script to return Input Email size Property -->
    <script>
        function myGeeks() {
            let email = document.getElementById("email").size;
            document.getElementById("result").innerHTML = email;
        }
    </script>
</body>
 
</html>


Output:

email-size

Example 2: This example illustrates how to set Input Email size Property.

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Input Email size Property
    </title>
</head>
 
<body style="text-align:center;">
 
    <h1>GeeksforGeeks</h1>
 
    <h2>
        HTML DOM Input Email size Property
    </h2>
 
    <label>E-mail:</label>
    <input type="email" id="email"
        name="myGeeks" size="10">
 
    <br><br>
 
    <button onclick="myGeeks()">
        Click Here!
    </button>
 
    <p id="result"></p>
 
    <!-- Script to set Input Email size Property -->
    <script>
        function myGeeks() {
            let email_size = document.getElementById(
                "email").size= "30";
 
            document.getElementById("result").innerHTML
                = "Value of size attribute changed to "
                + email_size;
        }
    </script>
</body>
 
</html>


Output:

email-size-2

Supported Browsers:

  • Google Chrome 5
  • Edge 12
  • Firefox 1
  • Opera 11
  • Safari 5


Last Updated : 29 Jan, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads