n92
n92

Reputation: 7602

How exactly declaring page doctype as HTML5 reduces the error in W3C markup validation

I have a website which has got around 1000 pages. I declared all html doctype to use XHTML 1.0 strict

I checked the website pages using W3C markup validation tool, I got 320 errors, Then I changed the doctype to HTML 4.0 the errors reduced to 300.

Then I used the HTML5 doctype, Then errors got reduced to 75. So How these errors got reduced by just changing the doctype.

EDIT

My Question is:

1) Validating my pages against XHTML1.0 standards gives me more than 300 errors, Which is quite huge and bit difficult to resolve them.

2) Validating my pages against HTML5 standards gives me around 70 errors, Which is not a issue and can resolve them easily.

So In this case which HTML version i have to use so that It does not affects SEO of the pages, Because w3c validation also affects the SEO

If i just use HTML5 doctype but not exactly the page structure (nav, header, section, footer, article ....), Will this really matters Because I have got around 1000 pages which is very difficult make them to follow the HTML5 page structure.

What i am thinking is to reduce the errors in w3c, I will just change the doctype to HTML5 and resolve the w3c errors. Is this a good idea. Or If any please suggest me.

Upvotes: 0

Views: 953

Answers (4)

user3092911
user3092911

Reputation: 1

It happens because xhtml uses xml parser, which demands more strict syntax. I've found it out that <!DOCTYPE html> is much more tolerant, for using standard that is still in developent (last subsentence is more my guess than concrete).

Upvotes: 0

Arkana
Arkana

Reputation: 2889

As @Quentin says, there are many differences between XHTML 1.0 Strict and HTML5. Apart from the new tags, there are other significative differences, some examples:

1 - All XHTML tags and attributes should be written in lower case.

  • Is there any uppercase tags or attributes in your code?

2 - In XHTML, when you use a singleton tag like <br/> you are required to include a trailing slash in the element for valid XHTML. In HTML 5, the trailing slash is optional.

  • Have you self-closing the singleton tags?

3 - All XHTML attribute values must be quoted. In HTML5, you don’t need to place quotation marks around attribute values if there are no spaces.

  • Are your attribute values properly quoted?

4 - All the XHTML tags must be nested properly.

  • Is this your case?

5 - The HTML5 <meta> tag with the charset attribute is simpler than in XHTML: <meta charset=utf-8>

  • If you're using this tag your document fails in XHTML

6 - There’s also no need to include the Type Attribute for Style Sheet Links and Scripts.

  • If you didn't declare this attribute, your document fails in XHTML

These are a few examples of how different can validation will be simply changing the Doctype. You could check these points to see if is there any your case.

You can retrieve all the info here: Baby steps from XHTML to HTML5

I will just change the doctype to HTML5 and resolve the w3c errors. Is this a good idea?

Well, HTML5 is more "easier" to construct, because is more flexible, but is a decision you must decide before start making the website. I suggest you to read the W3C specifications for XHTML 1.0 and HTML5 specifications, and then decide what language fits better with your requirements and how code it to have a valid markup.

Upvotes: 3

Walter Cameron
Walter Cameron

Reputation: 2383

Poor code is poor code, regardless of doctype. You will see fewer errors when validating with an html5 doctype because html5 as a spec is much less rigid in how it defines html to be structured.

Google doesn't validate pages. That said, better markup can help a search engine to better understand your website. Although if you're just changing the doctype and not cleaning up the poor code, it's not going to have an effect.

Upvotes: 2

Quentin
Quentin

Reputation: 943556

Because, quite simply, different versions of HTML are different and allow different things.

<video> for example is new in HTML 5 so will error in HTML 4.

Upvotes: 2

Related Questions