Hacker News new | ask | show | jobs
by ElectricalUnion 1041 days ago
> And yet to see a browser that actually cares about DOCTYPE...usually its pretty obvious when the next line is <html>

    How do browsers determine which mode to use?

    For HTML documents, browsers use a DOCTYPE in the beginning of the document to decide whether to handle it in quirks mode or standards mode.

    The DOCTYPE shown in the example, <!DOCTYPE html>, is the simplest possible, and the one recommended by current HTML standards. Earlier versions of the HTML standard recommended other variants, but all existing browsers today will use full standards mode for this DOCTYPE, even the dated Internet Explorer 6. There are no valid reasons to use a more complicated DOCTYPE. If you do use another DOCTYPE, you may risk choosing one which triggers almost standards mode or quirks mode.

    Make sure you put the DOCTYPE right at the beginning of your HTML document. Anything before the DOCTYPE, like a comment or an XML declaration will trigger quirks mode in Internet Explorer 9 and older.

    The only purpose of <!DOCTYPE html> is to activate no-quirks mode. Older versions of HTML standard DOCTYPEs provided additional meaning, but no browser ever used the DOCTYPE for anything other than switching between render modes.
https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mod...
1 comments

So no real use, got it. Luckily IE 9 has been gone for awhile

My point was its silly because the html self-defines being html the second you open the <html> tag, because what else could it even be?

> So no real use, got it.

If you don't care your site potentially becomes unusable broken shit outside of the specific browser you develop it on, there's no real use.

https://quirks.spec.whatwg.org/

I'm mistaken then; from the block you copy and pasted I misread it to suggest only IE 9 cares about quirks. In my personal use I'd never seen it matter cross-browser before

That said, HN works fine.

Of course HN works fine, if it didn't work fine it'd be fixed by now. "Working fine" is an extremely low bar for any site. As a developer you will still want to avoid quirks mode because it just makes your life harder for no reason.
What if the document has omitted the <html> tag?