How to calculate text width based on font size JavaScript

To calculate text width using Javascript, You need to use the canvas.measureText() method.

Demo : calculate text width Try it Yourself »