Like @C3roe says this code snippet works great i think. In the css code #page-container :not(a) > h2
excludes the a tags with h2
#page-container > h2,
#page-container :not(a) > h2 {
font-size: 20px;
color: #df1425;
font-family: Arial, sans-serif;
}
<div id="page-container">
<h2>I want this to have styling changes</h2>
<a>
<h2>
I don't want this to have styling changes because this is inside a tag
</h2></a
>
<div>
<h2>I want this to have styling changes</h2>
<a>
<h2>
I don't want this to have styling changes because this is inside a
tag
</h2></a
>
</div>