How to create custom tags for html


I'd like to learn how to create custom tags for html, with special attributes and behavior, if someone can give me links or advice I'd be the most grateful.

If you can redirect me to a "for dummies" tutorial would be better.

There's an interesting and in depth article from on how to work with custom elements : Custom Elements: Defining New Elements in HTML

Here's an excerpt from the article on how to do it.

Instantiating elements

The common techniques of creating elements still apply to custom elements. As with any standard element, they can be declared in HTML or created in DOM using JavaScript. Instantiating custom tags

Declare them:


Create DOM in JS:

var xFoo = document.createElement('x-foo');
xFoo.addEventListener('click', function(e) {

Use the new operator:

var xFoo = new XFoo();