HTML size Attribute:This attribute can be applied on <input>,<select> elements. When <input> element is used it specifies the visible width, in characters, of an <input> element.
HTML size Attribute
When an <select> element is used it specifies the number of visible options in a drop-down list.
Syntax: <element size = “number”>
Browser Support
This attribute is supported by the following browsers:
- Chrome
- Firefox
- Internet Explorer
- Safari
- Opera
Example: for <input> element
<!DOCTYPE html> <html> <body> <form action="/action_page.php"> Email: <input type="text" name="email" size="35"><br> Phone number: <input type="text" name="phone number" maxlength="10" size="10"><br> <input type="submit" value="Submit"> </form> </body> </html>
Output:
Example: for <select> element
<!DOCTYPE html> <html> <body> <select size="2"> <option value="C">C</option> <option value="C++">C++</option> <option value="HTML">HTML</option> </select> </body> </html>
Output: