10

Short question: Can I change the DOCTYPE of my existing XHTML 1.0 website to HTML5? Will this cause any problems?

Long story:

We've got a website written in ASP.NET webforms. Since it's pretty old, the default DOCTYPE is set to XHTML (default for Visual Studio) and all the controls render XHTML as well. Not extremely valid, but we've had no problems under any browsers so far.

That is, until recently we noticed some odd behavior on different machines under IE. Turns out that IE by default renders intranet websites in "compatibility mode", which breaks things down.

Now, I've got two choices. I can either add:

<meta http-equiv="X-UA-Compatible" content="IE=edge" >

Or I can add

<!DOCTYPE html>

I'd prefer the DOCTYPE route, since it would open the doors for a lot of neat HTML5 features. However I wonder if it won't have incompatibility problems with our existing XHTML layout.

Vilx-
  • 104,512
  • 87
  • 279
  • 422

3 Answers3

6

First up, IE does indeed render intranet sites in compatibility mode by default. However, it is a config setting and can be switched off: if possible, I'd suggest that your first solution would simply be to switch off this setting on all the machines on your network. (whether this is a viable solution will depend on the size of your network, your group policies, and what other intranet sites would be affected)

Now to answer your question.

The HTML5 doctype can be specified on any site that you want to render in standards mode. If you're already using XHTML, the only effect for you will be that the browser will no longer rigidly enforce strict XHTML compliance. You are perfectly entitled to continue using XHTML code, but it won't be enforced.

The HTML5 doctype was specifically chosen because it works with existing browsers, including older versions of IE. You should be able to put it onto any page, and it should just work.

What it won't do is have any effect at all on IE going into compatibility mode. Nor will any other doctype. The X-UA-Compatible solution you mentioned is the solution to this (unless you can set the config setting I mentioned earlier), and is un-related to the doctype - you'll still need it even if you use the HTML5 doctype.

Spudley
  • 166,037
  • 39
  • 233
  • 307
  • Since we distribute the app to many clients, many of which are also running other apps in their intranets, it would be foolish for us to ask to change their group policies because of our app. But thank you for confirming that HTML5 doctype is The Way To Go. :) – Vilx- May 17 '11 at 09:44
  • 1
    "the only effect for you will be that the browser will no longer rigidly enforce strict XHTML compliance" - That's not correct. Browsers have never enforced strict XHTML compliance. – Alohci May 17 '11 at 09:48
  • Argh! Should read more carefully. The last paragraph is the kicker. ;) Just found out the hard way. OK, so I implemented them both. :P Won't hurt. – Vilx- May 17 '11 at 10:58
3

As far as I know, HTML5 is pretty much xhtml plus the extras so yeah, I think you can change the doctype and it would still work. They answered it here: If I use HTML 5's doctype, what will happen?

Community
  • 1
  • 1
Elaine Marley
  • 2,143
  • 6
  • 50
  • 86
1

HTML5 was designed to be backwards compatible with both HTML 4.01 and XHTML 1.0/1.1, so that previous (X)HTML pages could be migrated to HTML5 easier. Of course, they wouldn't be taking advantage of new HTML5 features (such as new tags), but they would still be technically valid HTML5.

Kevin Ji
  • 10,479
  • 4
  • 40
  • 63