I'm trying to adjust the font-size
based on how visually or pixelualy(if that's a word) long the text is.
No, I am NOT talking about the text.length
of the variable. Uppercase and lowercase characters occupies different width on the <div>.
Because this div is fixed width the font-size
must adjust depending on the entire visual length the text will occupy, the longer the text is, the smaller the font-size becomes.
Here in the screenshot, there are some text wrapping on the next line but let's ignore that and focus on a property that I can get for the nCount of length/pixel-width the entire text occupies? Like how many pixels wide is the entire string of text? If the text wraps to the next line then that property must still count onward.
For example, if the uppercase letter 'A' occupies 6px wide but a lowercase 'a' occupies 4px wide only. What would the be the word 'Web developer' 's total line width in pixels then?
How do you get that property inside an HTML element?
NOTE: I know that text.length can be used to some extent but it is not perfect as it doesn't account for the visual width of upper/lower cases but rather the character count only.