3 ms·
Hi! I'm not a front-end person, I'm an ops guy, I live in the world of bash terminals and thread dumps. My knowledge of HTML and CSS is enough to make some head
by dvtrn 5y ago
Hi! I'm not a front-end person, I'm an ops guy, I live in the world of bash terminals and thread dumps. My knowledge of HTML and CSS is enough to make some headings and paragraphs. So pardon what might be to you folks who look at this daily-seem like a "duh" question.
The article says this:
You might think that this information is redundant because the browser already knows that the MIME type of the response is text/html; but in the Netscape/Internet Explorer days, browsers had the difficult task of figuring out which HTML standard to use to render the page from multiple competing versions.
Are there still a lot of browsers in use that have difficulty figuring out the HTML standard, and if not, is the doctype declaration just an anachronism of markup?
Asked in a less roundabout way: If response data is sufficient for a browser to know what it needs to do, and modern browsers support such capability: why do we still declare document types?
- jaywalk 5y agoIt's not that there's any "difficulty" in figuring it out, but it's literally part of the standard. An HTML 5 page will not render correctly without <!DOCTYPE html> even in modern browsers.
- dvtrn 5y agoOk, that's fair, it's in the standard. I suppose my real question is (and maybe this is a discussion that's been beaten to death and I'm merely ignorant of it): why does the standard require it, if modern technology seems to have obviated the need for it? Am I too far off the mark with "backwards compatibility" as a scientific wild-ass guess or is it more complicated than that? And if so, with what kind of devices/browsers that would still be in use today?
- jaywalk 5y agoIt is for backwards compatibility, but you're thinking about it in reverse. It's so that modern browsers can also render pages written to older standards correctly as well. They will not use "HTML 5 mode" unless the page explicitly declares that it's HTML 5. Nor should they, because you can't have a valid HTML 5 page without it.
- dvtrn 5y agoThe loud noise you're hearing is the sound of a bunch of old, rusty mechanical gears clanking into place. This explanation makes perfect sense to me now. I hadn't done much serious front-end things since high school in the early 2000's and even then I had no idea what "web standards" were. I just knew how to make pages and display images for a counter-strike 1.6 clan haha. Thanks for taking me to school.
- jaywalk 5y agoNo problem, glad I could help!
- ZeroGravitas 5y agoBrowsers include a lot of crazy backwards compatability stuff. You can basically trigger a whole different experience with the right/wrong doctype line. I guess it'll disappear eventually and become an opt out rather than an opt-in, but not sure if we're there yet, IE11 has been a major drag on progress.
- csnover 5y agoIt can never disappear and become an “opt out” without breaking backwards compatibility. This has nothing to do with old browsers, but rather, old content. You can’t go back in time and rewrite every HTML file ever published in order to have them “opt in” to quirks mode.
- jeroenhd 5y agoMost browsers have quirks modes for different types of HTML standards. Certain errors are renderered in certain ways because that's what web devs used to expect, even if they weren't following the standard. If you strictly enforce XHTML1.1 or HTML4 because the website says that's the standard it follows, you end up with tons of broken websites. It's a consequence of websites historically being lenient with front end developers. The HTML5 string basically says "I promise to be good, please turn off your weird workarounds". Of course, HTML5 has been around long enough that some browsers still have certain quirks, but they're not as extensive as the ones before HTML5. Compared to the `<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd http://www.w3.org/TR/html4/loose.dtd">` monstrosity from before, I'll happily take the modern standard. There's no version number anymore, just a simple HTML identifier.