Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is colon : valid in attribute names for HTML(5)?

Tags:

html

Is a colon : character valid an attribute name in HTML(5)?

Like this:

<p he:llo="world" >Hello world</p>

After searching the web I found this article:

http://razzed.com/2009/01/30/valid-characters-in-attribute-names-in-htmlxml/

That says it's valid, but he links to this w3-document:

http://www.w3.org/TR/2000/REC-xml-20001006#NT-Name

But this article is entitled "Extensible Markup Language (XML) 1.0 (Second Edition)" - meaning, XML and not HTML.

Could anyone clarify this for me?

like image 602
corgrath Avatar asked Apr 15 '13 17:04

corgrath


1 Answers

This is used for XML namespaces and should not be used for other purposes as per that document you referenced:

The Namespaces in XML Recommendation [XML Names] assigns a meaning to names containing colon characters. Therefore, authors should not use the colon in XML names except for namespace purposes, but XML processors must accept the colon as a name character.

HTML5 supports both an XML mode and a non-XML mode. I would stay away from colons except as namespace delimiters.

like image 67
Dark Falcon Avatar answered Sep 16 '22 15:09

Dark Falcon