What are namespaces in HTML?

It's pretty straightforward I am trying to understand the namespaces in HTML.

What's the difference between using these two commands. Why should be used createElementNS over createElement?

const a = document.createElementNS("http://www.w3.org/2000/svg", "svg")
const b = document.createElement("svg")

Resources:

https://developer.mozilla.org/en-US/docs/Web/API/Element/namespaceURI

https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement

https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement



Read more here: https://stackoverflow.com/questions/66278014/what-are-namespaces-in-html

Content Attribution

This content was originally published by Joozty at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: