Are you unable to use numbers on CSS font family names?
So I was last night coding a little thing to randomize the font used in a part of the title of my page, and it works perfectly. However, I ran into an issue regarding numbers in the font name. As you can see in the image, I have an array of fonts, pick one at random, and then use a template literal to change the font to the element's style. The font is called 1942 Report, and so I called it 1942 in the @font-face declaration in CSS. However, this didn't seem to work within the javascript code. It did however, work when I manually set that font into the font-family attribute within the stylesheet. Are font names not supposed to ever have numbers? Or is it the javascript that inserts it in a different way? I couldn't find anything about this online except for one person that seemingly had a similar issue with numbers, so I'm curious about it
Of course, I don't need to have numbers in my fonts and I'll just avoid using them if it causes issue, but I would like to know what is going on
2 Replies
Not sure, but did you try putting extra quotation marks around it?
Oh I very much did not, and now I do see that I made a mistake thinking that quotation marks would have come included !! Haha that makes a lot of sense as to why that didn't work
I'll try it in a second and see if that marks this post as solved haha
Yep that seems to be the fix, thank you very much !! I'll be more mindful of this in the future haha