+1

Why the font-size gets applied to "Hello" text alone and not the "yes" text?

https://code.sololearn.com/WzDDQn6ArpKD/?ref=app As the "yes" text is a <p> tag inside another <p> which contains "Hello" text, mustn't the font-size be applied to both?

4/9/2020 3:33:22 PM

Srinath

2 Answers

New Answer

+2

A <p> paragraph element can only contains inline elementd. A <p> paragraph element is of type block... So, a <p> cannot be in a <p> nor have a <p> inside it. Anyway, html us permissive, and browers are intented to try theur best even if the html code is not valid: <p class="myclass">hello <p>world</p> ! </p> ... is interpreted as the valid code: <p class="myclass>hello</p> <p>world</p> <p>!</p> ... where no <p> is child of another p. So, class 'myclass' is only applied to the first part of the breaked <p> (only to 'hello', not to 'world' nor to '!' ^^

+2

Oh now i get it. Thanks for the explanation