+ 1
Why do 'my' html contents get rendered even when I intentionally delete all other elements or tags?
Deleting/omitting a single end of statement character in Java for example, would result in compile error
3 Respostas
+ 2
HTML is different than scripting. When you omit text formatting, it's usually safe for browsers to just guess -- and they do. The tags/content you DO use often provide hints as to what section should have been started (so that's generally what happens).
The inconvenient aspect of this behavior is that all browsers guess slightly differently, and if you get in the habit of relying on getting your layouts fixed for you, you set yourself up for strange problems + may have a really hard time figuring out why.
The darker side is that in some cases -- knowing that browsers will 'help' something that's wrong in some special way -- sites have been 'hacked' by tricking some tag-rendering engine to fix something for you, causing unintended side-effects leading to compromise.
+ 1
Here's a test you can do yourself on Sololearn, showing an incorrect guess.
Paste the following into a new code's *empty* HTML tab:
<script>
alert(document.all[0].outerHTML);
</script>
Run it. Notice how it was placed into <head> and there's no <body> tag. That's wrong (this is definitely incorrect according to what usually happens), but it works fine, right?
It's still (probably) unintended behavior.
+ 1
thank you Kirk for your sleek, precise and easily understood answer. It has shade a lot of light to my earlier research on this. Great Mod!