It works pretty well but I don’t want it applied to page 46. I’ve tried using the :not pseudo class but without success so far. My syntax is probably wrong. What is the correct syntax, please? Thanks.
The class that you are avoiding is attached to the body element so you are saying that when the body does not have that class applied then process the following rule for the page wrapper.
The class you are avoiding is the starting point for your selection because that’s where it has been placed. You have to work downwards from there to find the matching descendant selector (#page-wrapper),
The body has a class of .page-id-46 and you want to target a descendant of the body if the body doesn’t have that class.
It’s sort of the reverse of using that body class to target an element.
e.g.
The normal way to target a descendant element based on a parent class.
.page-id-46 #page-wrapper {
display:block;height:auto;/* for example*/
}
When you use :not you are saying only apply the styles if this class is not present on a parent.
CSS works from the top down so you can’t say #page-wrapper:not(class on the body element) even if that was valid. What you say is :not class on the body then choose the descendant to style which in your case would be #page-wrapper.
It may seem curious but it’s really just the scope of basic CSS.
By omitting the body selector from the rule the :not rule will apply to any parent of #page-wrapper no matter what that element is. It is basically shorthand for:
*:not() etc…
The universal selector is optional in this case.
:not()
So your rule will work when the body has the class you are looking for or indeed if the html element (or any other parent of #page-wrapper -if any) has the class you are looking for.
Either of your two rules would be ok in this case but adding the body selector to the rule makes it more obvious where you expect to find this class and of course the css parser has less work to do (although this is seldom an issue).
Generally I would not add a tag selector to a class name but in this case as there is always only one body element in a page it makes sense to use it.