As a general reminder, you should always look at what HTML code you generate. There are three important layers:
Your PHP template.
The generated HTML code (use your browser’s “View Source” view, Ctrl/Cmd+U in most browsers).
You generally don’t need to check all three layers all the time, but in front of an error it can be useful to do just that. For instance in your case:
<!-- PHP source -->
<h1><?php echo $something ?></h1>
<!-- HTML result -->
<!-- Document tree -->
The P element is illegal inside a H1, so the browser closes the H1 immediately, then you have a paragraph, and finally it discards the </h1> closing tag (which is now matched with nothing, since the H1 is already closed).