Someone else commented on appending to the head element with a full style element and that's not bad if you're only doing it once but if you need to reset it more than once you'll end up with a ton of style elements. So to prevent that I created a blank style element in the head with an id and replace the innerHTML of it like this:
<style id="pseudo"></style>
Then the JavaScript would look like this:
var pseudo = document.getElementById("pseudo");
function setHeight() {
let height = document.getElementById("container").clientHeight;
pseudo.innerHTML = `.class:before { height: ${height}px; }`
}
setHeight()
Now in my case I needed this to set the height of a before element based on the height of another and it will change on resize so using this I can run setHeight()
every time the window is resized and it will replace the <style>
properly.
Hope that helps someone who was stuck trying to do the same thing.