New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: new element for measurements <m> #6319
Comments
I think for the common case of a number followed by a standard abbreviation it would make sense to not require the unit and value. That is, Also shouldn't |
@Yay295 you're right, "process" should be after the closing tag. Parsing is pretty simple when you have everything formatted as number + unit, however there are plenty of cases that are hard or impossible to parse, some examples: Using a standardized way to enter units and values would solve all these without a complex parser (even google's search engine can't get all of the above right). |
Which is why I specified "for the common case of a number followed by a standard abbreviation". I did read your more detailed explanation first. |
Thanks for the suggestion! However, HTML already has you covered: you can use the One simple example of this would be the following, which I made up off the top of my head: <data value="20">twenty <span itemprop="unit">miles</span></data>
<data value="2" itemscope>two ounces<meta itemprop="unit" content="oz"></data> but probably you want to use one of the more standardized examples from https://schema.org; from what I can tell QuantitativeValue might be what you want. I'll close this, since the general problem of providing structured data for tools has been solved generically using |
Even if we use Many other units are also problematic (such as writing "square/cubic meters" without resorting to superscript symbols) and until there is a universally accepted standard there won't be a simple way to make all these machine-readable. I opened this issue specifically as a way to solve machine-readability, which will then make unit conversions a trivial matter. All other attempts by 3rd party extensions and microdata to solve this problem have failed. The problem that I think deserves solving is helping people use the web seamlessly and across cultures and barriers as Sir Tim Berners-Lee intended: Even if the existing <data value="2" itemscope>two ounces<meta itemprop="unit" content="USfloz"></data>
<data unit="USfloz" value="2">two ounces</data> Here's a rough sketch of what interface I believe would make browsing much easier: Thanks for the time and I hope you reconsider, manual and tedious unit conversion is a problem that can be solved. |
I recommend reaching out to https://wicg.io/ and see if you can turn this into a compelling case there. |
One of the issues is that cooking ingredients which are measured in the Imperial and US Customer systems using "dry measure" volumes are measured in grams in the SI metric system. One of my hobbyhorses is that in the US customary system the pound, abbreviation "lb" is used interchangeable for both units of mass and units of force. For example in aerospace engineering the performance of an engine is measured as pounds(force) divided by fuel rate (pounds (mass) per second) to produce the Specific Impulse in seconds! In metric you divide the thrust in newtons (force) by the fuel rate in kilograms (mass) per second to get the effective velocity of the exhaust in m/s. The effective velocity is the specific impulse multiplied by the acceleration of gravity 9.80665 m/s2. |
The proposed measure element would be a text-level element representing a physical attribute such as length, area, volume, mass, weight, temperature, speed, acceleration, etc.
Syntax
Rationale
The measuring systems in modern use are the metric, imperial, and US customary systems and web users are forced to interrupt their browsing journey to convert units that are not native to them.
Google Search has been answering conversion queries for at least 16 years so we can infer that the demand for unit conversion is indeed huge.
A
<m>
element would provide standardized hooks for measurements, which would make client-side conversion of units between measurement systems much easier to accomplish. Any site would then be able write a script to convert it, browsers extensions could be easily created to convert units across the web, and browsers themselves could offer it as built-in function similar to page translation (available in Chrome and Safari).Use cases
The
<time>
,<a>
, and<abbr>
elements in HTML already expect information for one entity in two formats - one user-facing text content between the opening and closing tags, and one attribute value usually following a certain protocol/standard.Future Development
This new element would become much more powerful if a new browser/OS preference for metric/imperial/US customary units can be introduced within the Intl or Navigator objects. This would allow any script to automatically convert measurements when appropriate for a given user (similar to how browsers offer page translations).
A convert attribute
convert="never|auto|eager"
or similar would hint which measurements are (not) suitable for conversion.An examples of how this element might look like in the real world:
I've written a more detailed explanation on why such an element would solve many problems, it also includes sections on why writing a parser couldn't achieve the same results and why I think microformats are inferior to a brand-new text-level element.
The text was updated successfully, but these errors were encountered: