<!DOCTYPE html>
<style>
div { color: red; }
div::first-line { color: green }
</style>
<div id="x"><span id="y">green</span></div>
<script>
x.offsetWidth;
x.insertBefore(document.createTextNode('This should be '), y);
</script>