[whatwg] Form input element for value-unit pairs

Jukka K. Korpela jkorpela at cs.tut.fi
Mon Mar 14 13:09:26 PDT 2011


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/ 




More information about the whatwg mailing list