<!doctype html> <style> #a { display: contents; } #a::before { content: "" } </style> <marquee> <div id="a"></div> </marquee> <script> document.body.offsetTop; a.remove(); </script>