I want to apply the page-break-inside:avoid property to all p elements that do not have a ul element.
p {
margin-top: 4pt !important;
margin-bottom:6pt !important;
page-break-inside:avoid;
orphans: 4;
widows: 2;
}
<p>Hello text </p>
<p>hello <ul>
<li>list </li>
</ul>
I want to exclude the second paragraph. Is it possible through CSS? I am looking for a CSS solution.
You can't use the
ulinside apelement. As for the identifier topic, the only option for this would be to use the:haspseudo class, but it's still not compatible.You can check its documentation here.
Revise your code to improve the structure.
What you could do is something like this:
This way if you want to affect a
ulthat's right after apyou could use this selector: