Why, in the case of using the <p>
tag, sibling combinators are applied to an element that does not have a common parent.
Here the style is applied to the and the text of the child block turns red :
div~div {
color: red;
}
<div>Блок 1</div>
<p>Paragraph 1
<div>Child Block 1</div>
</p>
Here the style is not applied and the text inside the div does not turn red:
div~div {
color: red;
}
<div>Блок 1</div>
<section>Section 1
<div>Child Block 1</div>
</section>
Does <p>
have some hidden property or is there an invisible common parent of <div>
blocks?
` element is automatically closed by the `
element from the reference book again and realized that I did not attach importance to the phrase "If there is no closing tag, it is assumed that the end of the paragraph coincides with the beginning of the next paragraph or other block element"
– Kolenbass May 15 '23 at 21:01