Reputation: 649
I was having a discussion with a project lead and arguing the case for cleaning up our HTML generator. It often produces code that looks like this in the middle of a page:
...
<section id="ctl00_JUMBOTRON" class="jumbotron text-center jumbotron-fluid py-0 mb-0 d-print-none" Style="background-color:#FFFFFF" runat="server">
<div runat="server">
<div runat="server">
<body>
<!-- Begin Site Header -->
<div>Test Site Header</div>
<!-- End Site Header -->
</body>
</html></body>
</div>
</div></section>
...
This code "works" in the sense that the element looks right on the page but it is obviously incorrect. There are <body>
tags inside the existing body, a </html>
where it shouldn't be and multiple </body>
tags.
I know this is incorrect and our team know this is incorrect but it isn't a priority to our lead as it currently "works fine" in browsers (Firefox, Chrome, Edge...).
What are some examples of this NOT working besides not being correct?
Upvotes: 0
Views: 110
Reputation: 63
There can only be one <html>
tag and one <body>
tag on an HTML page. Browsers are very forgiving and tend to ignore invalid HTML. However, there could be unwanted or varying results across browsers.
Use an HTML validator, such as the W3C Markup Validator, to check the markup validity. This should be the standard used. You can see exactly what errors and warnings appear for your HTML in question.
Upvotes: 1