Steve Fenton

Set a minimum font size

This is just a little script I needed to use to increase text size conditionally. It only increases text below a minimum size and leaves everything else. Please also see a more recent post on CSS Clamp!

(function () {
    var minFontSize = function () {
        $(".content-zone *").each(function () {
            var $this = $(this);
            if (parseInt($this.css("fontSize"), 10) < 16) {
                $this.css({ "font-size": "16px" });


Before Image

Text Size Before

After Image

Text Size After

You can see that the span element is the same size before and after, but all the tiny text has been increased to the minimum size.

Written by Steve Fenton on