HTML | DOM Input URL size Property

The DOM Input URL size Property in HTML DOM is used to set or return the value of the size attribute of an Input url Field. The size attribute is used to define the width of a url field. Its default value is 20.

Syntax:

  • It returns the Input url size property.
    urlObject.size
  • It is used to set the Input url size property.
    urlObject.size = number

Property Values: It contains a single value number which is used to specify the width of a url field in terms of the number of characters.



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

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

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        DOM Input URL size Property
    </title>
</head>
  
<body>
    <center>
        <h1 style="color:green;"
                GeeksForGeeks 
            </h1>
  
        <h2>
          DOM Input URL size Property
      </h2>
  
        <label for="uname"
               style="color:green">
            <b>Enter URL</b>
        </label>
  
        <input type="url"
               id="gfg"
               placeholder="Enter URL"
               size="20">
  
        <br>
        <br>
  
        <button type="button" 
                onclick="geeks()">
            Click
        </button>
  
        <p id="GFG"
           style="color:green;
                  font-size:25px;">
      </p>
  
        <script>
            function geeks() {
                
                var link = 
                    document.getElementById(
                      "gfg").size;
                
                document.getElementById(
                  "GFG").innerHTML =
                  link;
            }
        </script>
    </center>
</body>
  
</html>

chevron_right


Output:

Before Clicking On Button:

After Clicking On Button:

Example-2: This Example illustrates how to set the size Property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        DOM Input URL size Property
    </title>
</head>
  
<body>
    <center>
        <h1 style="color:green;"
                GeeksForGeeks 
            </h1>
  
        <h2>
          DOM Input URL size Property
      </h2>
  
        <label for="uname"
               style="color:green">
            
            <b>
              Enter URL
          </b>
        </label>
  
        <input type="url" 
               id="gfg" 
               placeholder="Enter URL" 
               size="20">
  
        <br>
        <br>
  
        <button type="button" 
                onclick="geeks()">
            Click
        </button>
  
        <p id="GFG"
           style="color:green;
                  font-size:25px;">
      </p>
  
        <script>
            function geeks() {
                
                var link =
                    document.getElementById(
                      "gfg").size = "40";
                
                document.getElementById(
                  "GFG").innerHTML = 
                  "The value of the size"+
                  " attribute was change to "
                + link;
            }
        </script>
    </center>
</body>
  
</html>

chevron_right


Output:
Before Clicking On Button:

After Clicking On Button :

Supported Browsers: The browser supported by DOM input URL size Property are listed below:

  • Google Chrome
  • Internet Explorer 10.0 +
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Recommended Posts:



    Article Tags :
    Practice Tags :


    Be the First to upvote.


    Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.