<!doctype html> <style> div { display: contents; } </style> <math></math> <script> let div = document.createElementNS('http://www.w3.org/1998/Math/MathML', 'div'); document.querySelector('math').appendChild(div); </script>