I have an HTML page with one line of code:
<p>Hello World</p>
When I open developer tools and go to the elements tab the following code shows up:
<html>
<head></head>
<body>
""
<p>Hello World</p>
</body>
</html>
Why is Developer Tools adding this, and can it be prevented?
Because you are looking at the DOM in dev tools. This is what the browser does with the html to show you your page.
In the same way if you traverse a table missing the
<tbody>element in the HTML. This element still exists in the DOM.Just because it’s there in dev tools does not mean it’s in the HTML.
EDIT: Use view source/Resources in the dev tools to check what the server is sending.