I have a problem similar to this, but not identical to it...
In my case I have the following layout:
<span class="title">Title1:</span>
<span class="content">Content1</span>
<span class="title">Title2:</span>
<span class="content">Content2</span>
<span class="title">Title3:</span>
<span class="content">Content3</span>
<span class="title">Title4:</span>
<span class="content">Content4</span>
Which is displayed like this:
Title1: Content1
Title2: Content2
Title3: Content3
Title4: Content4
with the help of the following CSS
span.title{
font-weight: bold;
}
span.content::after {
content: "\a";
white-space: pre;
}
However, there will be a case where the first span.title
will be orphan - not followed by a span.content
but rather by another span.title
. In that special case, I want the orphan span.title
to be in its own line... So it will be like this:
Oprhan title
Title1: Content1
Title2: Content2
Title3: Content3
Title4: Content4
What's the correct rule to cover that :not() case?
I've tried quite many variations like the one below, but non seems to work...
span.title::after + :not(span.content) {
content: "\a";
white-space: pre;
}
Thanks a lot in advance!
EDIT: Basically, the more I think about this, the more I suspect it can't be solved in CSS... +
operator selects the element after it, not before it...