Probably my CSS knowledge is limited, but I don't uderstand this:
<p style="color: green">
<p style="color: red">This is red</p>
This should be green. But it's not.
</p>
The second line will render in black ignoring the "color:green". Why? I tested it in Chrome 28 and Firefox 22.
You cannot nest P elements it is illegal. The P element represents a paragraph. It cannot contain block-level elements (including P itself).
The <p> tag defines a paragraph. Browsers automatically add a single blank line before and after each <p> element. Tip: Use CSS to style paragraphs.
You can't nest paragraphs.
Paragraph is an auto-closing element, the </p>
is optional - any block element will automatically close the last open <p>
.
This is what's happening:
<p style="color: green">
</p> <!-- auto-closed paragraph -->
<p style="color: red">
This is red
</p>
This should be green. But it's not.
</p> <!-- here you have syntax error -->
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With