W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2011

[whatwg] Form input element for value-unit pairs

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Mon, 14 Mar 2011 22:09:26 +0200
Message-ID: <5854973080DC4986A434D46A91E88445@JukanPC>
Christoph P?per wrote:

> A new type is probably not necessary, because a new attribute that is
> called something like ?unit? and is only valid in the ?number? and
> ?range? states could be enough.
>
>   <input type="number" id="fontsize" value="12" unit="pt">

I don't quite see the point (no pun intended). It seems that the unit="pt" 
attribute just says that the input number will be interpreted as a number of 
points, i.e. a certain unit will be implied. This sounds unnecessary, as the 
form data processing can handle such things without any extra attributes.

Or do you mean that the presence of the unit="..." attribute would trigger a 
special implementation of numeric input, so that the user is expected to 
enter both a number and a unit, with the latter defaulted according to the 
unit attribute?

> I?m not sure, though, how UAs are supposed to know which other units
> could be substituted ? standard abbreviations perhaps: reference CSS3
> Values or SI / ISO/IEC 80000.

There is a huge number of units that might be used, and are actually used, 
so I'm afraid that would open a large can of worms.

Although the need for number & unit input is relatively common, I think it 
can quite satisfactorily be handled using a number input field and e.g. a 
dropdown menu of units accepted by an application (or maybe a textfield). 
After all, processing of the form data would most probably want to split a 
combined number & unit data item into its components, so why put them 
together in the first place?

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/ 
Received on Monday, 14 March 2011 13:09:26 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:31 UTC