Css selectors request

Here is a small piece of code.

<style ...>
h1 { color: red }
h2 { color: olive }
em { color: red }
h1 em { color: blue }
</style ...>

<body>
<H1>This <h2>headline is <EM>very</EM> important</h2> to me.</H1>
</body>

I even tried this code in jsfiddle, but I could not understand WHY the last two words are displayed in black for me . I thought it would be red.

+5
source share
2 answers

This is because you cannot embed h1-h6 tags. The tag <h2>implicitly closes <h1>, so it is interpreted as:

<body>
<H1>This </H1><h2>headline is <EM>very</EM> important</h2> to me.
</body>
+7
source

Note that styles should go in the section <head>.

But can you try putting it in a stylesheet?

And what is ...in tags <style>?

0
source

All Articles