Open In App

HTML DOM Input Email size Property

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:



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.




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

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




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

Supported Browsers:


Article Tags :