HTML | size Attribute
The size attribute in HTML is used to specify the initial width for the input field and a number of visible rows for the select element.
The size attribute can be used with the following elements:
- <input>
- <hr>
- <select>
<input> size Attribute: This attribute specifies the visible width of input element.
Syntax:
<input size = "value">
Example:
<!DOCTYPE html> <html> <head> <title>HTML size Attribute</title> <style> h1, h2 { text-align: center; } </style> </head> <body> <center> <h1 style="color: green;"> GeeksforGeeks </h1> <h2> HTML size Attribute </h2> <!-- It is the default size --> Name: <input type="text"> <br> <br> <!-- It's user specified size with value 50 --> Email-id: <input type="text" size="50"> </center> </body> </html> |
Output:

<select> size Attribute: This attribute specifies the number of visible options in a drop-down list.
Syntax:
<select size = "value"> option values...</select>
Example:
<!DOCTYPE html> <html> <head> <title>HTML size Attribute</title> <style> h1, h2 { text-align: center; } </style> </head> <body> <h1 style = "color: green;"> GeeksforGeeks </h1> <h2> HTML size Attribute </h2> <p>Sorting Algorithms</p> <select size="3"> <option value="merge"> merge sort </option> <option value="bubble"> bubble sort </option> <option value="selection"> selection sort</option> <option value="quick">quick sort</option> <option value="insertion">insertion sort</option> </select> </body> </html> |
Output:

<hr> size Attribute: This attribute specifies the height of the horizontal line.
Syntax:
<hr size = "value">
Example:
<!DOCTYPE html> <html> <head> <title>HTML size Attribute</title> <style> h1, h2 { text-align: center; } hr { background: green; } </style> </head> <body> <h1 style = "color: green;"> GeeksforGeeks </h1> <h2> HTML size Attribute </h2> <hr size = "26"> </body> </html> |
Output:

Supported Browsers: The browsers supported by size attribute are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | <hr> size Attribute
- HTML | <input> size Attribute
- HTML | <select> size Attribute
- HTML | <font> size Attribute
- HTML | <basefont> size Attribute
- What is favicon and what is the size of it in HTML?
- HTML | DOM HR size Property
- How to set checkbox size in HTML/CSS?
- HTML | low Attribute
- HTML | value Attribute
- HTML | min Attribute
- HTML | name Attribute
- HTML | <map> name Attribute
- HTML | <li> value Attribute
- HTML | alt attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet




