March 24, 2012

Are custom elements valid HTML5?

Question by user1282216

I’ve been unable to find a definitive answer to whether custom tags are valid in HTML5, like this:

<greeting>Hello!</greeting>

I’ve found nothing in the spec one way or the other:

http://dev.w3.org/html5/spec/single-page.html

Douglas Crockford claims:

Custom HTML tags have always been allowed in HTML. In HTML 5 they
become first class

… but he offers no proof.

http://www.crockford.com/html/

And custom tags don’t seem to validate with the W3C validator.

So if anyone can help me definitely answer this, please do!

Thanks!

Answer by Starx

Its not

XML

Creating your own elements in HTML is possible but not valid[Spec]. That’s what XML, SGML and other are for. HTML has a set of rules, which browsers, search engine understand and perform. Why do you want to mess around with that?There is a always a better way

There is a javascript technique that is used to enable HTML5 in IE browsers.

document.createElement(elementName)

You can use this to create any element and have CSS style it as well.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!