Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to create custom HTML tags?

user-image
Question added by Deleted user
Date Posted: 2014/09/20
Muhammad Waqas
by Muhammad Waqas , Dot Net and MVC Developer , Osys Technologies

Custom elements are created using document.registerElement():

Example:

var myFoo=document.registerElement('my-Foo')

document.body.appendChild(new myFoo());

 

The first argument to document.registerElement() is the element's tag name. The name must contain a dash (-). So for example, <x-tags><my-element>, and <my-awesome-app> are all valid names, while <tabs> and <foo_bar> are not. This restriction allows the parser to distinguish custom elements from regular elements but also ensures forward compatibility when new tags are added to HTML.

 

Mahmoud Elmahdi
by Mahmoud Elmahdi , UX/UI Designer, Web Developer , ikantam.com

If you're looking to create your own tag, then there's several ways to do it!* Polymer by Google https://www.polymer-project.org/

* Pure js as ( as showing in the prev answer )

* Angularjs 

Pugazhenthi Chandraboss
by Pugazhenthi Chandraboss , Marketing Manager , Pugazh TV

<HTML>

</HTML>

 

must be include slash tag before save the page like </html>

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.