I am trying to get my pages validated using Markup Validation Service on W3C validator.

We are getting validation against the XHTML 1.0 Strict doctype comes back with the following error:

[…] there is no attribute "data-gid"

Because of the following code:

<a href="#" class="addToCartLink" data-gid="202">Add to Inquiry List</a>

We have been advised that we need to use the HTML5 doctype. We have changed to the above doctype on this page now however the point of this excercise was to make sure the site is clean to help with SEO.

I would like to use the HTML5 doctype with HTML5 markup.

Here is the question: Is there any difference, from SEO perspective, between valid HTML5 or XHTML 1.0 Strict? Should I try to stay on (valid) XHTML 1.0 Strict doctype/markup or is it OK to move to valid HTML5 doctype/markup?


1 Answer 1


You need to familiarize yourself with DOC-TYPE markups.

At the moment your attempting to use both HTML5 and XHTML which is not possible, its one or other.

So at the moment you using:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

For HTML5 it should look like:

<!DOCTYPE html>

If you want it to Validate in XHTML 1.0 Transitional then it should look like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


The attribute data-gid is only valid in HTML5 so your pages should only use <!DOCTYPE html> if you want to validate your pages in XHTML then you need to remove the data-gid attribute and use another attribute that is supported in XHTML. Your pages validate absolutely fine when using HTML5 validation, so your only problem is that you need to remove: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> as this line is not required for HTML5 markup.

SEO Factors

There is no major or minor SEO value in using XHTML or HTML5 markups, as long as the page validates then Google, Bing and Yahoo will process your data without problems. The good thing is that your page is validating with HTML5. Time to focus on other things ;)

  • both of you - thanks so mcuh and for being so quick - really appreciated! Apr 15, 2013 at 14:35
  • Agree 99% with your answer. However I find adding "rich snippets" is easier using Microdata, which an HTML5 standard. And Microdata markup can really help with SEO. Of course the same can be achieved using XHTML 1.0 and RDFa or Microformats, but having as many tools at one's disposal is usually preferred, IMHO. Apr 15, 2013 at 19:38
  • use schema which is fully html5 compatible and most promising out of all of the formats Apr 15, 2013 at 19:47
  • Just to be clear, invalid HTML code is not bad for SEO. Only in the very rare case that it's a complete tag soup mess that cannot be parsed. Apr 15, 2013 at 23:45
  • Most SEOs agree that W3C validation does matter when it comes to SEO, but only for errors that cause bad rendering. Apr 16, 2013 at 0:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.