Search code examples
jqueryhtmlw3c

W3C validation error with data-href


I am getting one validation error due to my use of data-href="" in the context of making a whole DIV clickable. The JS and HTML is below. What could I do to make this W3C compliant?

JQUERY

$(function(){
$(".linked").click(function(){
window.location = $(this).attr("data-href");
return false;
});
});

HTML

<div class="" data-href="link.html"></div>

Solution

  • If possible, you should consider using a doctype that supports data-* attributes. For HTML5, that's:

    <!DOCTYPE html>