JSFiddle - React, Tailwind, and code Playground

HTML

<div id="demo">
        Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
        Donec id elit non mi porta gravida at eget metus. Nulla vitae
        elit libero, a pharetra augue. Nullam id dolor id nibh
        ultricies vehicula ut id elit. Vivamus sagittis lacus vel
        augue laoreet rutrum faucibus dolor auctor.
    </div>

JavaScript

$(document).ready(function() {
        var content = $('#demo').html();
        content = content.replace(/(\w|\s)/g, '<span>$1</span>');
        $('#demo').html(content);
        
        // Check each <span> for its offsetTop
        var highest_top = 0;
        var tmp_top = 0;
        $('#demo span').each(function() {
            tmp_top = $(this)[0].offsetTop;
            if (tmp_top > highest_top) {
                highest_top = tmp_top;
            }
        });
        
        // Collect total width
        var total_width = 0;
        $('#demo span').each(function() {
            check_top = $(this)[0].offsetTop;
            if (check_top == highest_top) {
                total_width += $(this).width();
            }
        });
        
        console.log(total_width);
    });