The visible part of the HTML document should be located between <body> and </body>. So this current example of markup is not correct according to W3C. You should avoid using this, but this code will be rendered correctly.
In other words, you can use the following convenient elements inside of a header tag in HTML5: a, em, strong, code, cite, span, br, img.
Read more: Is it valid to have paragraph elements inside of a heading tag in HTML5 (P inside H1)?
Omitting the html, head, and body tags is certainly allowed by the HTML specs. The underlying reason is that browsers have always sought to be consistent with existing web pages, and the very early versions of HTML didn't define those elements. When HTML 2.0 first did, it was done in a way that the tags would be inferred when missing.
In the HTML5 standard, the <html> tag, the <body> tag, and the <head> tag can be omitted.
The following code will validate as HTML5:
<h1>This is a heading</h1>
This is a paragraph.