<html xmlns="http://www.w3.org/1999/xhtml"> <body> <table id="table"> <caption id="c1">PASS: Text in caption 1</caption> <caption id="c2" style="opacity: 0.5">PASS: Text in caption 2</caption> <caption id="c3" style="opacity: 0.2">PASS: Text in caption 3</caption> <caption id="c4" style="opacity: 0">PASS: Text in caption 4</caption> </table> <script> var caption = document.createElement('caption'); caption.appendChild(document.createTextNode('PASS: Dynamically added caption')); var table = document.getElementById('table'); var c1 = document.getElementById('c1'); table.insertBefore(caption, c1); document.body.offsetTop; </script> </body> </html>