How is this possible??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

How is this possible???

We know that only information which is provided in the meta tag is displayed on the webpage but I don't understand that when I wrote "hi" in head tag, it displayed on the webpage. Why? https://code.sololearn.com/W28YxPjKJCRJ/?ref=app

20th May 2020, 12:53 PM
Divyanshu Singh
Divyanshu Singh - avatar
7 Answers
+ 5
visph The question is why is "hi" render when it was written in the head of the HTML document. The answer is "Browsers fix any invalid content and go on" according to the site "How Browsers Work: Behind the scenes of modern web browsers" see link in my previous post. The code I linked is related to this post in that I wanted to give an exaggerated example. So I copied Divyanshu Singh code and misaligned the tags to go along with the site I referenced to, again see my previous post for the link. The point was to show how the browser will correct the programmer's mistakes. This is not a Sololearn Playground issue it is the browser doing what it is programmed to do. But you are right in that I should have logged out the HTML document to make the point clearer. Which I have now done. https://code.sololearn.com/WVuGfVfzX2Cc/#js
22nd May 2020, 12:44 AM
ODLNT
ODLNT - avatar
+ 4
Browsers' error tolerance "You never get an "Invalid Syntax" error on an HTML page. Browsers fix any invalid content and go on." source: 'How Browsers Work: Behind the scenes of modern web browsers' https://www.html5rocks.com/en/tutorials/internals/howbrowserswork/#Browsers_error_tolerance https://code.sololearn.com/WVuGfVfzX2Cc/#html
20th May 2020, 3:23 PM
ODLNT
ODLNT - avatar
+ 4
The playground does have some drawbacks, but this isn't one of the. And depending on what device you are using they are different. But that is for a different post.😉 Yeah, HTML most definitely a free and relax markup language.😜
20th May 2020, 4:14 PM
ODLNT
ODLNT - avatar
+ 2
I thought sololearn's playground has some drawbacks ODLNT
20th May 2020, 3:37 PM
Divyanshu Singh
Divyanshu Singh - avatar
+ 2
Thanks for explaining this ODLNT .
22nd May 2020, 3:17 AM
Divyanshu Singh
Divyanshu Singh - avatar
+ 1
Divyanshu Singh: put this snippet in the js tab, and see how the html engine has closed the <head> element prematurly (document.documentElement refer to the root <html> element, <style> and <script> tags are added by playground at end of <head> BEFORE html engine parse the html source): onload = function () { alert(document.documentElement.innerHTML); }; ODLNT: why linking a code not related with the OP question?
21st May 2020, 11:29 PM
visph
visph - avatar
0
That means HTML is not so strong like Python, C++, etc.
20th May 2020, 3:38 PM
Divyanshu Singh
Divyanshu Singh - avatar