/

HTML / CSS / JavaScript Tutorial

HTML Standard attribute: size

[this page | pdf | back links]

The HTML size attribute indicates the width in characters for <input> elements or number of visible options for <select> elements.

 

Valid attribute values (when used with <input> elements) include:

 

Value

Description

integer

Number of characters that identify the width of the element

 

Valid attribute values (when used with <select> elements) include:

 

Value

Description

integer

Number of visible options in drop-down menu

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<input type="text" value="size = 20" size="20">

<br><br>Created using JavaScript:<br>
<span id="element"></span>

<script>
var x = document.createElement("INPUT");
var att1 = document.createAttribute("value");
att1.value = "size = 25";
x.setAttributeNode(att1);
var att2 = document.createAttribute("size");
att2.size = "25";
x.setAttributeNode(att2);
document.getElementById("element").appendChild(x);
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile