Remix.run Logo
alt227 11 hours ago

This is exactly why HTML is so ubiquitous, because it is so tolerant of mistakes in formatting, syntax, and just about anything else.

Most browsers will even read and process most of the things listed on this page because even if the spec doesnt say so, it just makes sense to anyway.

quectophoton 11 hours ago | parent | next [-]

React.js with JSX (which people use to avoid writing HTML) is basically the opposite on its tolerance for mistakes but somehow it seems pretty popular, to say the least.

win311fwg 10 hours ago | parent [-]

JSX is a little pickier about structure, but doesn't give much care towards conformance, which is where the bulk of HTML violations occur. I expect close to 98% of React output is also invalid, which is why users are using React and not something like Qt.

dylan604 11 hours ago | parent | prev [-]

Is HTML that way because of it being HTML, or have browsers just decided to brute force their way into handling the slop so that people won't blame the browser for not doing it correctly?

alt227 11 hours ago | parent | next [-]

In my experience a lot of the "best practice" warnings are reductive.

A couple examples from this list are not requiring a type parameter on certain tags, or style tags being valid under html and body tags but not div tags. These types of things would take extra coding in a browser to check for certain singular tags not requiring things that all others do. Therefore it is simpler to leave these checks out and leave sloppy syntax checking as it does no harm at all to the rendered markup.

You may be right in some situations, but the nature of HTML having everything applied to all tags and then selectively reduced definitely helps make it a more resilient and accommodating language.

shevy-java 11 hours ago | parent [-]

Totally agreed.

ndiddy 11 hours ago | parent | prev [-]

Well it's obviously a better experience for someone who's not the page author if the browser tries to render an invalid page rather than throwing up its hands and showing an error. That way you can at least try to read the page rather than not being able to and having to track down the author and try to get him to fix his site. The "strict parsing" fans tried to force correctness with XHTML, but it was a failure and didn't see much use.

The main problem with "handling the slop" used to be that different browsers would render invalid HTML differently, so poorly written sites could look very different depending on the browser you used. Modern HTML standardizes how browsers handle invalid HTML so this isn't a problem anymore. See https://html.spec.whatwg.org/multipage/parsing.html