5

What is the correct way to set type units in HTML? Stuff like

2km

Do I just put the unit right after the value as above? Or is there a special short space? If so how do I prevent a line break between value and unit? How about combined units like

3Ah

where A stands for Ampere and h for hours does anything special go between A & h?

  • 1
    You might add a   between the units but this is not really needed. There is a space between the number and the unit. – joojaa Aug 17 '14 at 8:52
2

There is a space between the value and the unit - I think a nbsp should do.
I'm not sure about the "Ah" case. It's A times h, so it should be written with space "A h" (or with dot, "A·h") according to the text below; but "Ah" feels ok to me. For combining a unit with a prefix, there is no space between them - it is "2 km" for metres with the prefix kilo.

One would ask scientists how to write physical units, of course. And scientists use TeX/LaTeX for this, so it's a good idea to look there:

There is a TeX package describing how to render units in all detail.
LaTeX package "siu­nits" – In­ter­na­tional Sys­tem of Units.
See for example "2.4.1 Space between numerical value and unit symbol" on page 15.
It documents various special cases too, like that the temparature "10 °C" has a space, but the angle "10°" does not.

  • no full space between A and h, degree is not a unit symbol – joojaa Aug 17 '14 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.