4

I am learning HTML 5 and have a question: Can HTML 5 be used in XHTML 1.1 documents? If yes, then could anybody give an example?

noob
  • 8,982
  • 4
  • 37
  • 65

2 Answers2

8

Do not confuse XHTML and HTML.

XHTML is HTML ruled to be a valid XML document. Actually the XHTML 1.1 standard does not apply to HTML 5 but to HTML 4.01.

What does it mean? You can pick a valid XHTML 1.1 document and it'll be a valid HTML 5 document but the counter-part is not always true. For example:

<button disabled></button>

It's valid HTML code (it doesn't matter which version) but it's not a valid XML statement (then it's not a valid XHTML document) because of the empty attribute. World is full of these examples (just Google), HTML is very relaxed about syntax (and HTML 5 didn't change this direction) and there are some other differences too (here, for an example). Moreover the HTML 5 standard introduced new tags that aren't part of XHTML 1.1 standard so a fully featured HTML 5 document (despite the syntax) won't be a valid XHTML 1.1 document.

References
Here a short list of good reference about this topic, selected from SO answers:

Community
  • 1
  • 1
Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208
1

theoretically no, because the standard sets of xhtml and html are different. However, if it is working is totally depending on the browser you use and most modern browser will show the other set of tags as well as the standard you have defined.

Abby Chau Yu Hoi
  • 1,378
  • 3
  • 15
  • 37