Size attribute for an input field not being honored

Viewed 43644

Taken directly from W3Schools:

Definition and Usage The size attribute specifies the width of an input field.

For <input type="text"> and <input type="password">, the size attribute defines the number of characters that should be visible. For all other input types, size defines the width of the input field in pixels.

So..

If that is true why is my field <input type="text" size="2"/> wide enough to display 5 CAPTIAL MMMMM's ?

5 Answers

The other/outer css class may affect the size or inline CSS.

My case is:

when using an outer div with a class "input-group", the size or inline style will not work at all. Removing this class of "input-group" if possible will make it work.

<div class="input-group">
    <input type="text" class="form-control" required style="width:20px">
</div>
Related