1

Is this really needed when we data-attr for the elements in html

<input type ="text" name="text1" id ="text1" data-attr="<?php echo $hell ?>">

2 Answers 2

6

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.
Sign up to request clarification or add additional context in comments.

Comments

2

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="...").

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.