HTML Interview Guidebook

The Machine
In this article I’m going to solve the HTML questions from this GitHub repo

What does a doctype do?

The doctype declaration tells the browser to render the page using the HTML5 specification (full standards mode) and it has to be the first thing in the HTML document, before the <html> tag which contains the <head> and the <body> of the document. Anything before the doctype declaration can trigger the implementation of quirks mode or almost standards mode.

What’s the difference between full standards mode, almost standards mode and quirks mode?

There are three standards used by the web browsers: full standards mode, almost standards and quirks mode. The quirks mode emulates nonstandard behaviour in Netscape 4 and IE5 in order to support websites built before the web standards integration. In full standards mode the behaviour is the one specified by the HTML and CSS specifications while in almost standards mode there are a few quirks implemented.

What’s the difference between HTML and XHTML?

XHTML, in a nutshell, is a stricter version of HTML (HTML defined as an XML application), version which must be valid at parsing time. If there are any errors on render, it should fail to display the content on the device. On the internet there are loads of webpages which use a bad HTML, that’s why a stricter version was created. XHTML deprecates Javascript methods like document.write() and write access to the .innerHTML property, because they can be used to insert invalid code that would break the document structure.

What is bad HTML?

The XHTML documents must contain a doctype, an <html> tag with an xmlns attribute, <head>, <title> and a <body>.

Are there any problems with serving pages as application/xhtml+xml?