6

My site is currently using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

However, things like Facebook plugins are only valid in HTML5. So, is it safe to change my DOCTYPE to <!DOCTYPE html>? Will this affect anything?

0b10011
  • 18,397
  • 4
  • 65
  • 86
Maarten Kuilman
  • 481
  • 2
  • 6
  • 21
  • 1
    [This](http://stackoverflow.com/q/5629/1267663) and [this](http://ejohn.org/blog/html5-doctype/) may help – Whymarrh Apr 05 '12 at 14:43
  • I think you should use XHTML doctypes only if the page is really XHTML, otherwise it's better to use one of the HTML ones. And if you care about validation, and your site with a Facebook plugin doesn't validate under your current doctype, then by all means do get rid of the plu- oops, I mean use the HTML5 one. – Mr Lister Apr 05 '12 at 14:50

5 Answers5

4

Yes you can change your DOCTYPE,it will not affect anything that you have already done.In HTML 5 you will get some new features which you can use for your future purpose.Just check this link and you will get some idea about the features present in HTML 5

NewUser
  • 12,713
  • 39
  • 142
  • 236
  • 2
    But be careful with using HTML 5 tags, not everything is supported in all browsers, mainly IE7 and IE8 which hold a pretty big market share still. – Nick Bork Apr 05 '12 at 14:52
  • 1
    yes..I am agree with you.The link above I have mentioned will give some idea about which browser will support which tags of HTML5 – NewUser Apr 05 '12 at 14:55
  • 1
    The use of new HTML5 features does not require a doctype change. – Jukka K. Korpela Dec 01 '14 at 10:42
  • What if I have obsolete tags in HTML5 such as , table width/padding attributes in my HTML 4.x file? Because once I added new doc type to my old html page some borders, padding looks different in table tags. – Lahiru Ruhunage Aug 12 '15 at 04:59
3

You can change it. Almost all browsers just look for html in the doctype to ensure they are parsing HTML. It will also remain the same with new versions of HTML.

You might want to do the following quick changes to the head element:

  • Change the meta element to <meta charset="utf-8">.
  • Drop type="text/css" when linking stylesheets and drop type="text/javascript" in script elements as these are the default values.
melhosseiny
  • 9,992
  • 6
  • 31
  • 48
1

Change your DOCTYPE as you said, it shouldn't affect what you've already done in HTML4, but it does give you options of some of the new HTML5 features in future.

Martin Oxby
  • 23
  • 1
  • 8
1

The only thing that such a doctype change will affect is validation. Other than that, the doctype declaration only affects browser mode (quirks / almost standard / standard), and XHTML 1.0 and HTML5 doctype have the same effect in this respect.

If you don’t use a validator, there is no reason to change. If you do, you should select the doctype according to which HTML version your document is closer to. Besides, HTML5 validation is completely different from XHTML 1.0 validation (heuristic mixed-strategy checking vs. formal well-defined but limited checking).

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
0

It shouldn't affect anything, but it's considered good markup to leave it as it is. HTML5 should work anyway.