This translation is incomplete. Please help translate this article from English.

Selectorul :not() CSS pseudo-class reprezinta elementele care nu corespund unei liste de selectori. Deoarece previn un specific item pentru a fi selectat, este stiut ca pseudo-class negatie.

/* Selecteaza orice element care NU este un paragraph */
:not(p) {
  color: blue;
}

Notes:

  • Useless selectors can be written using this pseudo-class. For example, :not(*) matches any element which is not an element, so the rule will never be applied.
  • This pseudo-class can increase the specificity of a rule. For example, #foo:not(#bar) will match the same element as the simpler #foo, but has a higher specificity.
  • :not(.foo) will match anything that isn't .foo, including <html> and <body>.
  • This selector only applies to one element; you cannot use it to exclude all ancestors. For instance, body :not(table) a will still apply to links inside of a table, since <tr> will match with the :not() part of the selector.

Syntax

Selectorul  :not() pseudo-class necesita ca argument o lista formata din unul sau mai multi selectori separati prin virgula. Lista trebuie sa nu contina o alta negatie selector sau alte pseudo-elemente.

Abilitatea de a lista multipli selectori este experimentala si nu este vast implementata si suportata de catre toate browserele.

:not( <selector># )

Example

HTML

<p>Eu sunt un paragraph.</p>
<p class="fancy">Eu sunt atat de fancy!</p>
<div>Eu NU sunt NOT un paragraph.</div>

CSS

.fancy {
  text-shadow: 2px 2px 3px gold;
}

/* <p> elements that are not in the class `.fancy` */
p:not(.fancy) {
  color: green;
}

/* Elements that are not <p> elements */ 
body :not(p) {
  text-decoration: underline;
}

/* Elements that are not <div> or <span> elements */
body :not(div):not(span) {
  font-weight: bold;
}

/* Elements that are not `.crazy` or `.fancy` */
/* Note that this syntax is not well supported yet. */
body :not(.crazy, .fancy) {
  font-family: sans-serif;
}

Result

Specifications

Specification Status Comment
Selectors Level 4
The definition of ':not()' in that specification.
Working Draft Extends its argument to allow some non-simple selectors.
Selectors Level 3
The definition of ':not()' in that specification.
Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 1Edge Full support YesFirefox Full support 1IE Full support 9Opera Full support 9.5Safari Full support 3.2WebView Android Full support 2Chrome Android ? Edge Mobile Full support YesFirefox Android Full support 4Opera Android Full support 10Safari iOS Full support 3.2Samsung Internet Android ?
Selector list argumentChrome No support NoEdge No support NoFirefox No support NoIE No support NoOpera No support NoSafari Full support 9WebView Android No support NoChrome Android No support NoEdge Mobile No support NoFirefox Android No support NoOpera Android No support NoSafari iOS Full support 9Samsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

Document Tags and Contributors

Contributors to this page: rolikc
Last updated by: rolikc,