Size attribute for an input field not being honored

前端 未结 4 1702
不思量自难忘°
不思量自难忘° 2020-12-28 14:28

Taken directly from W3Schools:

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

For

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-28 14:54

    The answer is that, unless using a fixed width font, the browser can't accurately determine the width of two characters. I think your two character field would probably fit two "m"s side-by-side.

    As far as the correctness of w3schools, the following is from the W3C:

    size = cdata [CN] This attribute tells the user agent the initial width of the control. The width is given in pixels except when type attribute has the value "text" or "password". In that case, its value refers to the (integer) number of characters.

    http://www.w3.org/TR/html4/interact/forms.html#edef-INPUT

提交回复
热议问题