[whatwg] A tag for measurements / quantity?
Tab Atkins Jr.
jackalmage at gmail.com
Tue Aug 11 06:14:58 PDT 2009
On Tue, Aug 11, 2009 at 12:58 AM, Max Romantschuk<max at romantschuk.fi> wrote:
> Hi Everyone,
> I've been off the list for quite some time, so bear with me if I missed
> something searching the archives.
> I've been looking at the meter element, which specifically states that
> "There is no explicit way to specify units in the meter element, but the
> units may be specified in the title attribute in free-form text."
> Having used the web for the past 15 years I've always felt that it's a shame
> when you run into a page with a set of measurements and those can't be
> interpreted automatically in a sensible fashion. Especially with the fact
> that there are both imperial and metric units still around in this day and
> An backwards compatible inline element to specify a quantity would be rather
> <quantity unit="cm">12 cm</quantity>
> <quantity unit="kg">2 kg</quantity>
> With this implementation a number inside the quantity element would be
> interpreted as the numerical value of the unit. Other characters would be
> ignored. That way old browsers would simply ignore the unknown tag, whereas
> a browser aware of this tag could provide DOM hooks for things like
> implementing a browser extension to convert between metric and imperial
> Food for thought. Opinions, anyone?
It would be good if @unit could be omitted and parsed from the content
as well in simple cases. In both of the examples you provide, it
would be trivial. /(\d+)\s*([a-zA-Z]*)/ would capture the quantity
and the unit in most cases.
I think a stronger case would be to provide automatic conversions to
one's preferred quantitative units, as has been discussed as a
possible use for <time>.
Are there stronger use-cases for this than just auto-conversion,
though? <time>, frex, allows for easy machine-scraping of time/date
data for adding things to calenders.
More information about the whatwg