CSS Selector for not a child of element type?

Solution 1:

:not does not support combinator selectors.

If we're talking about its direct parent:

:not(a) > code

Otherwise there's no way to do this in CSS. You'll have to override it:

code {
    /* some styles */
}

a code {
    /* override previous styles */
}

Solution 2:

Actually, you should be able to use your code 🤔, or you could use the wildcard character to select all elements to not be selected

code:not(a *) {
  font-weight: bold;
}

Codepen