0

For my website I would like to set the font size in cm (centimeters), so that the font is readable independently of screen size and resolution, as long as display PPI (pixels per inch) setting is set correctly in the OS. So I tried this in html:

<p style="font-size:1cm">Some text</p>

Apparently, neither on my PC, nor on mobile the font size is 1cm. On PC it's larger (too large to be readable). On mobile it's smaller (too small to be readable).

So the question is what's going on? Is this because PPI is not set correctly on both devices? Or is it because cm font sizes just don't work in the web/browsers?

Serge Rogatch
  • 13,865
  • 7
  • 86
  • 158
  • 1
    Possible duplicate of [How to set font size to exact physical size?](https://stackoverflow.com/questions/53922840/how-to-set-font-size-to-exact-physical-size) – str Jan 14 '19 at 21:49

2 Answers2

1

This is because cm is used for print and not to display into a Screen. font-size:1cm will approx the exact size on screen only for very large resolution.

Recommended

Sreen em, px, %

Print em, cm, mm, in, pt, pc, %

Occasional

Sreen ex

Print px, ex

Not Recommended

Sreen pt, cm, mm, in, pc

Community
  • 1
  • 1
Arthur
  • 4,870
  • 3
  • 32
  • 57
0

Absolute length units are fixed and a length expressed in any of these will appear as exactly that size.

Absolute length units are not recommended for use on screen, because screen sizes vary so much. However, they can be used if the output medium is known, such as for print layout.

https://www.w3schools.com/cssref/css_units.asp

Alfie
  • 2,341
  • 2
  • 28
  • 45