Is this really needed when we data-attr for the elements in html
<input type ="text"开发者_如何学JAVA name="text1" id ="text1" data-attr="<?php echo $hell ?>">
Is it needed? no. Will it pass the W3C validator without it? no.
You'll have no actual issues using data attributes either way, it just depends how important validation is to you.
- Without HTML5 DOCTYPE: It'll work, the validator will fail with an HTML4 doctype.
- With HTML5 DOCTYPE: It'll work and be valid.
No. You don't need to write your code any particular way.
You should provide the correct doctype for the content. If you'd like to add data elements/attributes in HTML4 and below, you can namespace your elements and attributes (mydata:attr="..."
).
精彩评论