Although it is generally advised against using such markup (as most people here would concur), I will provide you with a solution.
Assuming your base font size is 12px
, when the browser tries to fix this incorrect markup by removing the h3
from the p
, your p { font-size: 0.5em; }
rule does not take effect because it is no longer within a p
. As a result, the text size does not become 6px
as anticipated. In my example, the h3
now inherits the base font size of 12px
. Since 1em x 12px = 12px
, using 1em
does not alter the text size.
This is how the browser is handling it:
<p></p>
<h3>Title is here</h3>
This is the paragraph
<p></p>
Therefore, whatever the parent element is and its font size dictate the font size of the text string This is the paragraph
.
Hence, the straightforward solution is to increase the em
value for your h3
. However, there may still be unexpected outcomes in certain scenarios due to other CSS rules impacting the base font size caused by the improper markup and the actions of the browser.