JSFiddle - React, Tailwind, and code Playground

HTML

<p id="myUniqueId">foo bar</p>

JavaScript

var uId = (function(){
            for(var r='myUniqueId', i=1; document.getElementById(r+i); i++);
            return r+i;
          })()
,   div = document.createElement('div')
;

document.getElementsByTagName('head')[0]
        .appendChild(document.createElement('style'))
        .innerHTML = '#'+uId+ '{background-color:red;}'
                   + '#'+uId+ ' .test{background-color:yellow;}'; //just as example
div.id=uId;
document.getElementsByTagName('body')[0]
        .appendChild(div)
        .innerHTML='<p class="test">foo</p> <br> bar';  //just as example