The HTML validator looks at the page's Doc Type, usually the very first line of code in the page's HTML.
The Doc Type is a statement of which standard the document is supposedly following.
For bonus points, you could try to eliminate any warnings as well.
As you fix your markup to remove one error, you may find that you generate more-- or that suddenly several other errors go away.
In Django, you would write something like this: Nice summary.
encoding them, stuff can get dicey in weird edge cases and fail completely in XML.