I have the following code that is used to open a menu over the account anchor:
echo "<li><a href='./account/' data-flexmenu='account'>Account"</a></li>";
the data-flexmenu='account' inform what menu should be shown, in that case, the account menu.
The problem is that im getting error on w3 validator: there is no attribute "data-flexmenu"
Is there a way to make that valid?
I wouldn’t worry too much about validation. I think validated HTML is important but if your code works in all browsers and still doesn’t validate then what’s the point? Custom attributes will work in all browsers, even Internet Explorer 6. Custom attributes can also be parsed by Javascript and there’s no need for the HTML5 doctype to be able to do that.
There’s a great article by Nicholas Zakas, where he explains the value of validation using custom attributes as an example. See http://www.nczonline.net/blog/2010/08/17/the-value-of-html-validation/