![HTML Tutorial](/html/images/html-mini-logo.jpg)
- HTML Tutorial
- HTML - Home
- HTML - Introduction
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Headings
- HTML - Paragraphs
- HTML - Fonts
- HTML - Blocks
- HTML - Style Sheet
- HTML - Formatting
- HTML - Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - size Attribute
HTML size attribute is used to specify the initial width of the input field and the number of visible rows for the selected element.
For an input element, the size attribute specifies the visible width, in characters and for the select elements, the size attribute specifies the number of visible options in a drop-down list.
Syntax
<element size="value">
Applies on
Below-listed elements allow the use of the HTML size attribute.
Element | Description |
---|---|
<input> | HTML <input> tag is used to specify the input field. |
<select> | HTML <select> tag is used to create dropdown lists in online forms. |
Examples of HTML size attribute
Below examples will illustrate the HTML size attribute, where and how we should use this attribute!
Form input fields with different size
The output window displays the last name field with a larger size than the first name field.
<!DOCTYPE html> <html> <head> <title>HTML size Attribute in input tag</title> </head> <body> <h2> HTML size Attribute in input tag</h2> <form> firstName: <input type="text"> <br><br> lastName: <input type="text" size="50"> </form> </body> </html>
Dropdown list with more than one visible option
On executing the below code, based on the size attribute, drop-down list shows three options at a time.
<!DOCTYPE html> <html> <head> <title>HTML size Attribute in select tag</title> </head> <body> <h2>HTML size Attribute in select tag</h2> <p>Select the option of your choice:</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>
Supported Browsers
Attribute | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
size | Yes | Yes | Yes | Yes | Yes |
html_attributes_reference.htm
Advertisements