Hacker News new | ask | show | jobs
by petee 1041 days ago
In defense, half of these look like what I'd call "normal" HTML, granted I'm not up on the latest fads.

But "<center>" is depreciated now? Come on.

"Width" and "height" attributes too? To what purpose? They are clear, easy to use, and apparently still widely supported with no issue.

And yet to see a browser that actually cares about DOCTYPE...usually its pretty obvious when the next line is <html>

Edit: I seem to be mistaken about the importance of doctype for some situations.

3 comments

> 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...
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?
I'm a bit glad to see the HTML specification evolve rather than stay backwards compatible forever. The committee drew a line between logic, layout, and content. <center> is purely layout. I'm sad to see it go for nostalgic reasons and am often confused when I need to center a non-text, non-flexbox element, but centering does belong in "layout".

I just wish the Tailwind community (and those from other big-ass CSS frameworks) would internalize this concept. It feels so unintuitive to have your compiled HTML just element after element of class="lg:block fixed inset-0 top-[3.8125rem] drop-shadow-md justify-center hunter2-blue overflow-hidden pointer-events-none"

...especially when elements like <p> have the exact same giant class definition throughout an entire page.

> And yet to see a browser that actually cares about DOCTYPE

If a web page does not have the correct doctype, browsers run it in quirks mode instead of standards mode. If a web developer is fine with their websites running in quirks mode, they are not a good web developer, and you should probably stay away from them.