Why does Chrome ignore the text input size attribute?

The following size attribute has no effect. Why?

<input type="text" size="80" placeholder="blablabla bla lba bla bla bla blabla bla bla bla lba">

By default, it is 60 characters, and I can not do anything to change this.

+5
source share
5 answers

Presumably you have a style influencing it. Without any style rules, it works just fine . But when you apply a style rule with a smaller size, it takes precedence .

To find out which style rule affects it, right-click it and select Inspect Element, then see the style information shown on the right.

+3
source

textarea input:

<textarea cols="80" rows="1" style="overflow: visible" placeholder=
"blablabla bla lba bla bla bla blabla bla bla bla lba"></textarea>

, . overflow: visible , IE 80 , 79 , - .

input:

size="80" "" 80 . ( ""?), : size="80" , 4 20 . . . ( .)

input:

style="width: 80ch", CSS3, , . ch "0", . (, Firefox . , .)

<input> . , .

+1

Google Chrome 26 Mac OS Lion, "ch" .

width: 16ch " ". (pt, px, em,%) .

0

, 60 , , , maxlength:

MAXLENGTH

type , , , , tel url, ( Unicode), ; . size. , . ; . , .

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input

Size determines only the width of characters, not the amount that users can enter.

0
source

I had the same problem, and having tried many other solutions, I fixed it by adding width to the input fields.

input {
    width:90px; /* Your width may vary */
}
0
source

All Articles