• Post category:HTML

Step by step guide to set Input textbox size with Examples

HTML Textbox Size

In this article, we will see about how to set HTML textbox size. If you don’t know anything about size and maxlength attribute then you have come to the right place.  Let’s see the example code with steps:

How to set textbox size

  1. To Create a textbox, we need to create <input> tag and set the “type” attribute to “text“.
  2. We can set size of an textbox using “size” attribute. The default value of size attribute is 21, which means the textbox will display only 20 characters, if more than that the characters will be hidden on the leftside of the textbox.
  3. If we set “size” attribute to “15”, the textbox will display approximately 15 characters.
  <input type="text" size="15">


html textbox size

See the above output, the textbox allows more than 15 characters. If you maximum characters length of Input textbox, we need to use “maxlength” attribute. In the above code, we set the maxlength attribute to 15. It is used to the user don’t allowed to type more than 15 characters

<input type="text" size="15" maxlength="15">


html textbox size

So, you can use the “size” attribute is for text box size and “maxlength” attribute for users maximum input characters.  I hope you have understood a little about textbox size in this article. If you have any doubts about this then please comment below.

Leave a Reply