این ترجمه ناقص است. لطفاً در ترجمه این مقاله از انگلیسی کمک کنید.

not() CSS pseudo-class:  همه عناصر را انتخاب می‌کند بجز عناصری که به عنوان ورودی به این کلاس داده شود. از آنجایی که این کلاس از انتخاب عناصر خاصی جلوگیری می کند، به عنوان negation pseudo-class شناخته می شود.
 
/* 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

ورودی‌های شبه‌کلاس ()not: با ویرگول از یکدیگر جدا می‌شود.

 

 

The ability to list more than one selector is experimental and not yet widely supported.

:not( <selector># )

Example

HTML

<p>این عنصر، عنصر پاراگراف است.</p>
<p class="fancy">من چقدر خوبم!</p>
<div>این عنصر، عنصر پاراگراف نیست.</div>

CSS

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

/* نیستند `fancy` که دارای کلاس <p> ِتمام عنصار */
p:not(.fancy) {
  color: green;
}

/* <p> همه عناصر بجز عنصر */ 
body :not(p) {
  text-decoration: underline;
}

/* <span> یا <div> همه عناصر بجز عناصر */
body :not(div):not(span) {
  font-weight: bold;
}
/* را دارا هستند `fancy` یا `crazy` همه عناصر بجز عناصری که کلاس‌های */
/* توجه داشته باشید که این نوع نوشتار هنوز پشتیبانی نمی‌شود. */
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: dijam
Last updated by: dijam,