An HTML form with two input fields with a width of 35 and 4 characters:
![]()
The size attribute is supported in all major browsers.
The size attribute specifies the visible width, in characters, of an <input> element.
Note: The size attribute works with the following input types: text and password.
Tip: To specify the maximum number of characters allowed in the <input> element, use the maxlength attribute.
Since the size attribute is a visual design attribute, it is recommended to use CSS instead.
CSS syntax: <input style="width:100px" />
CSS Example: Set the width of an input field.
In our CSS tutorial you can find more details about the width property.
| Value | Description |
|---|---|
| number | Specifies the width of an <input> element, in characters. Default value is 20 |
HTML <input> tag
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $7.95/mo SEO Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| XML Editor - Free Trial! |
| FREE Website BUILDER |
| Free Website Templates Free CSS Templates |
| Make Your Own Website |
| W3SCHOOLS EXAMS |
|---|
|
Get Certified in: HTML, CSS, JavaScript, XML, PHP, and ASP |
| W3SCHOOLS BOOKS |
|---|
|
New Books: HTML, CSS JavaScript, and Ajax |
| STATISTICS |
|---|
|
Browser Statistics Browser OS Browser Display |
| SHARE THIS PAGE |
|---|