L
L
Leonid2018-02-06 17:14:22
css
Leonid, 2018-02-06 17:14:22

Nested paragraph selector - why doesn't it work?

There is this HTML code:

<p>Text 1</p>
<p>
  <p>Text 1</p>
</p>
<div>
  <p>Text 3</p>
</div>
<b>Text 4</b>
<b>
  <b>Text 5</b>
</b>

and CSS:
p {color: red;}
p p {color: green;}
div p {color: blue;}
b {color: grey;}
b b {color: blue;}

As a result, we have on the page:
d8li9o9bSfSVaz8tjPk26A.png
You can see an example here: https://jsfiddle.net/12mb0014/
It turns out that the nested selector: does not work, although the nested selector: works. Why?
p p {color: green;}
b b {color: blue;}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
#
#FFFFFF, 2018-02-06
@victory_vas

and you look through the inspector, as a result, the browser renders your layout. A paragraph cannot be nested within a paragraph.

C
cyberlain, 2018-02-06
@cyberlain

paragraph cannot be placed within a paragraph)

S
Socrates, 2018-02-06
@Karmov69

I wonder what forced such nonsense to write

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question