DEV Community

Discussion on: Calculate HTML Element width before render

Collapse
 
szalonna profile image
Joe

The font size is not the same as font width. If you use non-mono font, you cannot just assume, that the count of letters is in 1-to-1 ratio with the width of the container. Imagine the folloeing two word with the same char coun: wwwwww and llllll.

Collapse
 
ismailisimba profile image
Ismaili Simba

Ooh, so that's why it won't work unless you're using monospaced fonts

Collapse
 
sstraatemans profile image
Steven Straatemans

it inherits the style, so also the fonts. So it should be fine