The :not() CSS negation pseudo-class selector is a powerful tool in CSS styling. This functional pseudo-class selector allows you to specify a simple selector as an argument and then select elements that are not represented by that argument.
For more information, check out these resources: here and here.
When using the :not negation pseudo-class selector, remember that you can only use simple selectors.
To achieve your desired styling, follow this pattern:
.my-class :not([type='text']) {
//Add your CSS properties here
}
You don't need to include * as a selector because it already matches every element on the page. Additionally, eliminating the input selector can simplify your code.
Check out this jsFiddle example for reference.
CODE SNIPPET:
.my-class :not([type='text'])::after {
content: "selected";
border: 1px solid red;
}
<div class="my-class">
<input type="text">
<input type="checkbox">
<input type="radio">
<div class="element">Div</div>
<section>Section</section>
<h1>H1</h1>
</div>
The restriction to simple selectors in the :not pseudo-class is primarily for performance reasons.
Find out more about Fast vs Complete Selector Profiles and stay updated on potential changes in level four selectors regarding this restriction.