JSFiddle - React, Tailwind, and code Playground

HTML

<p>test</p>

JavaScript

var elements = document.getElementsByTagName('p');
for(var i=0,l=elements.length;i<l;++i) {

    var str = elements[i].textContent;
    elements[i].innerHTML = '';

    for(var j=0,ll=str.length;j<ll;++j) {
        var n = document.createElement('span');
        elements[i].appendChild(n);
        n.textContent = str[j];
        n.style.color = get_random_colour();
    }
}
function get_random_colour() {
    var color = '#';
    color += hsv2rgb(Math.random(),1,1);
    return color;
}

function hsv2rgb(h, s, v) {
    h = (h % 1 + 1) % 1; // wrap hue

    var i = Math.floor(h * 6),
        f = h * 6 - i,
        p = v * (1 - s),
        q = v * (1 - s * f),
        t = v * (1 - s * (1 - f));

    switch (i) {
        case 0: return intToHex(v, t, p);
        case 1: return intToHex(q, v, p);
        case 2: return intToHex(p, v, t);
        case 3: return intToHex(p, q, v);
        case 4: return intToHex(t, p, v);
        case 5: return intToHex(v, p, q);
    }
}

function intToHex(i,j,k) {  
    var hexR = parseInt(Math.round(255*i)).toString(16);  
    var hexG = parseInt(Math.round(255*j)).toString(16);
    var hexB = parseInt(Math.round(255*k)).toString(16);
    
    hexR = (hex.length < 2) ? "0" + hexR : hexR;  
    hexG = (hex.length < 2) ? "0" + hexG : hexG;  
    hexB = (hex.length < 2) ? "0" + hexB : hexB;
    echo hexR;
    return hexR + hexG + hexB;
}