JSFiddle - React, Tailwind, and code Playground

HTML

<body>
    <div id="bullText" class="tBorder">
        <div class="tBorder" id="bullTextArea">
           <div id='textImg' class='textImage'>
               WWWWWWWWW<br>
               WWWWWWWWW<br>
               WWWWWWWWW<br>
               WWWWWWWWW<br>
           </div>
        </div>
    </div>
</body>

JavaScript

resizeImg();
function resizeImg () {
        var w=document.getElementById("textImg").offsetWidth;
        var h=document.getElementById("textImg").offsetHeight;
        alert(h+" "+w);
        if (w>300 || h>300) {
            if (w>300) {
                var factor=((300/w));
            } else {
                if (h>300) {
                    var factor=((300/h));
                }
            }
            w*=factor;w=Math.round(w);
            h*=factor;h=Math.round(h);
            document.getElementById("textImg").style.width=w+"px";
            document.getElementById("textImg").style.height=h+"px";

        }
    }