Skip to content Skip to sidebar Skip to footer

What Happens If You Use Custom Attribute In A Html Tag?

this question isn't related to jQuery itself but I found a plugin named Metadata found there and one of the example uses custom tag attribute:
  • Solution 1:

    The browser won't care, since very, very few browsers actually validate the HTML. It will fail if you try to treat it as XHTML though, since it isn't valid XHTML.

    Solution 2:

    The browser wont care. Most (if not all browsers) just ignore illegal attributes. If you try to validate it, it WILL fail however. What you need to do is figure out if you're OK with this. If you are just keep the doctype. If not change the doctype. One thing to note is that even if you keep the doctype and the illegal attribute it wont impact your site in any way that it doesnt validate.

    In fact your markup might still validate if the data attribute is being added after the page loads - which means that at the point the validation occurs the data attribute wont be there.

  • Post a Comment for "What Happens If You Use Custom Attribute In A Html Tag?"