Question

Im having an issue with custom attrubutes in html5 document. My source code starts with the following code:

<!DOCTYPE html
[
 <!ATTLIST img pid ID #IMPLIED>
]>

When im trying to validate my html file in W3C validator it doesnt determine my documents doctype and tells that my doctype declaration is wrong. So my question is, how can I declare custom attributes in HTML5? Is it even possible at the moment in HTML5? I couldnt find any relevant information on the internet.

Was it helpful?

Solution

The DOCTYPE you are trying is invalid, it should be <!DOCTYPE html> which is a valid doctype for HTML5 and as far as the custom attributes go, you need to use data- prefix which will be considered as valid custom attribute.

<p data-custom-attribute="Value"></p>

[1] A custom data attribute is an attribute in no namespace whose name starts with the string data-, has at least one character after the hyphen, is XML-compatible, and contains no uppercase ASCII letters.

1. Reference

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top