Posted By

stephcode on 09/04/10


javascript DOM

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Create new DOM element

 / Published in: JavaScript


Thankfully, Sjoerd Visscher mentioned an interesting technique that could be used to force IE to use the specified CSS styling. Specifically, once you create a new DOM element (of the same name as the one in the document) all styling is applied. [...] This is very important. This now means that we can provide CSS styling for undefined HTML 5 element and allow Internet Explorer to handle it gracefully.

  1. <html>
  2. <head>
  3. <style>blah { color: red; }</style>
  4. <script>document.createElement("blah")</script>
  5. </head>
  6. <body>
  7. <blah>Hello!</blah>
  8. </body>
  9. </html>

Report this snippet  

You need to login to post a comment.