not Selector

not Selector
CSS not Selector reference
The CSS not negation pseudo-class selector ( X:not(Y) ) is used to NOT select a specified element type. Use it to exclude a specified element in an otherwise full sibling selection.
CSS CODE EXAMPLE
<!DOCTYPE html>
<style type="text/css">
#myDiv *:not(p) {
    color:#09C;
}
</style>
<div id="myDiv">
  <h3>My heading content</h3>
  <h4>My heading content</h4>
  <p>My paragraph content...</p>
  <p>My paragraph content...</p>
</div>
 

My heading content

My heading content

My paragraph content...
My paragraph content...
In the example above we first target the DIV element by its HTML ID attribute value. Then we add the Universal Selector after it in order to target all child elements within the DIV. Finally we use the not() selector to not style an element by its type so it does not get styled with all other elements inside the DIV universally with all of the other siblings of the DIV.

0 Response to "not Selector"

Post a Comment