The Input URL size property returns/sets the size property for input URL. If not defined this property returns ‘20’.
Syntax
Following is the syntax −
- Returning size attribute
inputURLObject.size
- Set size property to a number
inputURLObject.size = number
Example
Let us see an example for Input URL size property −
<!DOCTYPE html>
<html>
<head>
<title>Input URL size</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>URL-size</legend>
<label for="URLSelect">URL:
<input type="url" id="URLSelect" size="10">
</label><br>
<input type="button" onclick="increaseVisibility()" value="Increase Visibility">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputURL = document.getElementById("URLSelect");
function increaseVisibility() {
inputURL.size = 30;
divDisplay.textContent = 'Visibility Increased to '+inputURL.size;
}
</script>
</body>
</html>Output
This will produce the following output −
Before clicking ‘Increase Visibility’ button −

After clicking ‘Increase Visibility’ button −
