0
votes

I know there are different doctypes for html and xhtml as well as between strict, transitional, etc. but will someone encounter errors if using transitional html but declaring the doctype as xhtml transitional? Is this a bad habit to develop, or is it completely flexible? Are there some errors that could happen that I am not seeing, or could it affect things such as CSS negatively? I've been working with precoded pages and packages lately and connecting them and some use html 4.01 transitional, some use xhtml 1.0 transitional and I'm curious what, if any, conflicts I could have later down the line. Thanks!

2

2 Answers

4
votes

Browsers don't care what the Doctype is beyond it being a Magic String that triggers Standards Mode, Almost Standards Mode or Quirks mode.

You should use the correct Doctype so that you can use a validator as a useful QA tool instead of one that throws up lots of errors because you write XHTML with an HTML Doctype.

0
votes

(List of DOCTYPE declarations: http://www.w3.org/QA/2002/04/valid-dtd-list.html)

XHTML doctypes are meant for XHTML files, while HTML doctypes are meant for HTML files.
That said, none of the browsers differentiate between XHTML and HTML by looking at the doctype declaration; they all determine the file type by the MIME type. So you don't actually get errors, it's only a bad habit.

By the way, your question is titled "DocType Definitions" but that's not really correct: the prolog on top of your document is called a Doctype declaration. The Doctype definition, or DTD, is the markup of the syntax you can use for your document, in the .dtd file.