JSFiddle - React, Tailwind, and code Playground

HTML

<h1 onmouseover="hilight(this)">One Two Three</h1>

CSS

h1 span.hilight {
    background-color: yellow;
}

JavaScript

hilight = function(el) {
    var str = el.textContent
    var words = str.split(' ')
    if (words.length > 2) {
        words[0] = '<span class="hilight">' + words[0] + '</span>'
        words[2] = '<span class="hilight">' + words[2] + '</span>'
        el.innerHTML = words.join(' ')
    }
}