Skip to content Skip to sidebar Skip to footer

javascript resize text example

Reading Time: < 1 minute

How to change / resize page font using javascript.Check this demo and download javascript resize text example.For a example if you click button, then page font size will be increase and after click another button then reduce font size.

Following funtion is getting parameter as value of increase and then change the body font size.

function resizeText(val) {
  if ( == "") { = "1.0em";
  } = parseFloat( + (val * 0.2) + "em";

How to use this function.

Increase font size
Reduce font size


You can change 0.2 value as you wish to multiplier.
Also you can change fontFamily, fontWeight, background, margin, padding,….. like css properties.
View Demo