Saturday 19 October 2019

html - Why do browsers append extra line breaks at the end of the body tag?

When loading an HTML document I find that the DOM body content is inconsistent with the body content in the HTML document.



For example, if you go to example.com the end of the HTML document looks like this:








I would expect the last child node of body to be \n.




However, when I access the DOM in JavaScript the textContent of the last child node is \n\n\n.



I tried this in Chrome and Firefox and both behave in the same way. What is the explanation for this behavior?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...