Size attribute ignored when type is number!

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Post Reply
CharlesEF
Posts: 148
Joined: November 21st, 2003, 4:56 am
Location: Edinburg, Texas

Size attribute ignored when type is number!

Post by CharlesEF »

Hi All,

I have the current version of Firefox installed on Win10 Pro 64-bit. I have found that when using an input element of the number type the size attribute is ignored. Bug?


Thanks for any help,

Charles
User avatar
Frenzie
Posts: 2135
Joined: May 5th, 2004, 10:40 am
Location: Belgium
Contact:

Re: Size attribute ignored when type is number!

Post by Frenzie »

Minimal test case?
Intelligent alien life does exist, otherwise they would have contacted us.
CharlesEF
Posts: 148
Joined: November 21st, 2003, 4:56 am
Location: Edinburg, Texas

Re: Size attribute ignored when type is number!

Post by CharlesEF »

morat
Posts: 6394
Joined: February 3rd, 2009, 6:29 pm

Re: Size attribute ignored when type is number!

Post by morat »

HTML input type “number” won't resize
http://stackoverflow.com/questions/22709792

HTML <input> size Attribute
http://www.w3schools.com/tags/att_input_size.asp
CharlesEF
Posts: 148
Joined: November 21st, 2003, 4:56 am
Location: Edinburg, Texas

Re: Size attribute ignored when type is number!

Post by CharlesEF »

Oh, since other browsers support the re-size but Firefox doesn't I have to use CSS instead. I mean, even IE 11 and Edge support this but Firefox doesn't!
User avatar
Frenzie
Posts: 2135
Joined: May 5th, 2004, 10:40 am
Location: Belgium
Contact:

Re: Size attribute ignored when type is number!

Post by Frenzie »

https://www.w3.org/TR/html5/obsolete.html#obsolete
Authors should not, but may despite requirements to the contrary elsewhere in this specification, specify the maxlength and size attributes on input elements whose type attributes are in the Number state. One valid reason for using these attributes regardless is to help legacy user agents that do not support input elements with type="number" to still render the text control with a useful width.
I'm not entirely sure I understand the rationale. Size is something different than min/max (or its regular input equivalent maxlength). Presumably it has something to do with this:

https://www.w3.org/TR/html5/sec-forms.h ... typenumber
The type=number state is not appropriate for input that happens to only consist of numbers but isn’t strictly speaking a number. For example, it would be inappropriate for credit card numbers or US postal codes. A simple way of determining whether to use type=number is to consider whether it would make sense for the input control to have a spinbox interface (e.g., with "up" and "down" arrows). Getting a credit card number wrong by 1 in the last digit isn’t a minor mistake, it’s as wrong as getting every digit incorrect. So it would not make sense for the user to select a credit card number using "up" and "down" buttons. When a spinbox interface is not appropriate, type=text is probably the right choice (possibly with a pattern attribute).
CharlesEF wrote:Oh, since other browsers support the re-size but Firefox doesn't I have to use CSS instead. I mean, even IE 11 and Edge support this but Firefox doesn't!
Chromia and WebKits seem to behave the same as Firefox so "other browsers" really just means one browser. ;)

(Edge is IE12 no matter what they call it.)
Intelligent alien life does exist, otherwise they would have contacted us.
Post Reply