How to increase Font Size in JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 14

How to increase Font Size in JavaScript

20th Jan 2022, 7:36 AM
Vaibhav
Vaibhav - avatar
3 Answers
+ 3
Hey there. For good practice, the Separation of Concerns is useful. There's nothing inherently wrong with using JS to change font size, but that is the domain of CSS. It is better to use JS to apply a CSS class to your HTML and change the size, and not style the font with JS directly. JS should govern behaviour, not presentation. Something to consider for you. Have a great day.
22nd Jan 2022, 2:03 AM
Ryan Hadley
Ryan Hadley - avatar
+ 2
for Canvas : context.font="50px" for html element: element.style.fontSize="50px"
20th Jan 2022, 4:45 PM
Vishal
Vishal - avatar