Assuming the following HTML elements:
<p>Paragraph.</p>
<div class="note">Naked Note Div.</div>
<div class="note">
<p>Paragraph in Note DIV.</p>
<p>Second Paragraph in Note DIV.</p>
</div>
<div>NON Note Naked Div.</div>
<div>
<p>Paragraph in NON None DIV.</p>
</div>
The desired output should be as follows:
Paragraph.
NOTE: Naked Note Div.
NOTE: Paragraph in Note DIV.
Second Paragraph in Note DIV.
NON Note Naked Div.
Paragraph in NON None DIV.
Attempting to achieve this using CSS pseudo class ::before has proven challenging, especially for someone new to this concept.
Using: CSS
.note::before {content: "NOTE: ";}
yields:
Paragraph.
NOTE: Naked Note Div.
NOTE:
Paragraph in Note DIV.
Second Paragraph in Note DIV.
When applying CSS
.note :first-child::before {content: "NOTE: ";}
, the result is:
Paragraph.
Naked Note Div.
NOTE: Paragraph in Note DIV.
Second Paragraph in Note DIV.
Is there a way to resolve this using only CSS without resorting to preprocessors or jQuery?