Actually, no. According to W3C standards, this markup is incorrect and should be avoided.
It is mentioned that header elements should contain "phrasing content", which consists of phrasing elements mixed with regular text.
In simpler terms, you can use the following elements within header tags in HTML5: a, em, strong, code, cite, span, br, img. View the complete list here.
Validating this markup using W3C validator will result in the error: Element p not allowed as child of element h1 in this context.
A major downside of using this markup is that search engines might misinterpret your heading tag, causing important data to be overlooked. This could negatively impact SEO.
To improve SEO outcomes, it is recommended to include only text content within heading elements. However, if styling is necessary, you can utilize the following markup and CSS:
<h1>
<span class="major">Main part</span>
<span class="minor">Sub part</span>
</h1>
<style type="text/css">
h1 span {
display: block;
}
h1 span.major {
font-size: 50px;
font-weight: bold;
}
h1 span.minor {
font-size: 30px;
font-style: italic;
}
</style>
Check out this jsfiddle for a live example.
It is acceptable to use the span tag within header elements (h1-h6) and apply "display: block;" style to render it as a block-level element. This eliminates the need for br tag.
Adjust the CSS selectors based on your specific requirements.
Furthermore, as mentioned by another user, using paragraphs inside headings is not semantically correct. Emphasizing the importance of prioritizing semantics over presentation in HTML.