<!doctype html> <style> fieldset::first-letter { border: inherit; } </style> <fieldset style="border: 10px solid red;"> This text should have a green border on the first letter. </fieldset> <script> document.body.offsetTop; document.querySelector('fieldset').style.borderColor = "green"; document.body.offsetTop; </script>