문제

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.

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top