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
ul
inside ap
element. As for the identifier topic, the only option for this would be to use the:has
pseudo 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
ul
that's right after ap
you could use this selector: