Html: Proposal : `unit` property for `input type="number"`

Created on 29 Oct 2019  Â·  3Comments  Â·  Source: whatwg/html

(Import of Issue 1417 in W3C/HTML)

I’d like to have to possibility to set a unit property on input type="number".

Browsers would be expected to display the specified unit close to the number (perhaps there would need a specific CSS option to specify if the unit should be before or after the figure, like for $10 vs 10€).

Assistive technologies would be expected to expose the unit to the user, and copy/paste would be expected to copy the number and its unit.

additioproposal needs implementer interest forms

Most helpful comment

Instead of only having this available for numeric inputs, it seems it could be more generally applied to all text-like inputs as prefix and postfix.

Or perhaps an even more general display-format attribute that accepts something like a JS template string.

All 3 comments

Instead of only having this available for numeric inputs, it seems it could be more generally applied to all text-like inputs as prefix and postfix.

Or perhaps an even more general display-format attribute that accepts something like a JS template string.

(Sorry, hit the wrong button…)

Heya, please see https://whatwg.org/faq#adding-new-features. In particular, start with step 1 and 2. What is the specific use case you are trying to accomplish which cannot be done today? This might lead you to questions like "how is this different from ::after", etc.

Was this page helpful?
0 / 5 - 0 ratings