In this section, we will learn what the size attribute is and how to use it.
What is size Attribute in HTML <input> Tag?
For <input> element of types text, search, tel, url, email, and password, you have a width big enough to see at least 20 characters in the field.
But sometimes we might have an input that takes a higher number of characters and hence might want the field to be big enough to be able to see the entire entered-characters or at least most of them.
This is where the size attribute can help! This attribute basically takes a number value which is equal to the number of characters we want to be visible in the target field.
For example, if the size is set to 50, that means the target field should be big enough (width-wise) so that people can see at least 50 characters in the box at the same time.
HTML size Attribute in <input> Tag Syntax:
<input type = “type” size = “character-wise-size”>
Example: using size attribute in HTML <input> tag
See the Pen using size attribute in HTML <input> tag by Omid Dehghan (@odehghan) on CodePen.