---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: noUnmatchableAnbSelector
description: Learn more about noUnmatchableAnbSelector
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="CSS" icon="seti:css">
## Summary
- Rule available since: `v1.8.0`
- Diagnostic Category: [`lint/correctness/noUnmatchableAnbSelector`](/reference/diagnostics#diagnostic-category)
- This rule is **recommended**, meaning it is enabled by default.
- This rule doesn't have a fix.
- The default severity of this rule is [**error**](/reference/diagnostics#error).
- Sources: 
  - Same as [`selector-anb-no-unmatchable`](https://github.com/stylelint/stylelint/blob/main/lib/rules/selector-anb-no-unmatchable/README.md)

## How to configure
```json title="biome.json"
{
	"linter": {
		"rules": {
			"correctness": {
				"noUnmatchableAnbSelector": "error"
			}
		}
	}
}

```
## Description
Disallow unmatchable An+B selectors.

Selectors that always evaluate to 0 will not match any elements.
For more details about the An+B syntax, see:
https://www.w3.org/TR/css-syntax-3/#anb-microsyntax

## Examples

### Invalid

```css
a:nth-child(0) {}
```

<pre class="language-text"><code class="language-text">code-block.css:1:13 <a href="https://biomejs.dev/linter/rules/no-unmatchable-anb-selector">lint/correctness/noUnmatchableAnbSelector</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">This selector will never match any elements.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a:nth-child(0) &#123;&#125;<br />   <strong>   │ </strong>            <strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Avoid using An+B selectors that always evaluate to 0.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">For more details, see </span><span style="color: lightgreen;"><a href="https://www.w3.org/TR/css-syntax-3/#anb-microsyntax">the official spec for An+B selectors</a></span><span style="color: lightgreen;">.</span><br />  <br /></code></pre>

```css
a:nth-last-child(0n) {}
```

<pre class="language-text"><code class="language-text">code-block.css:1:18 <a href="https://biomejs.dev/linter/rules/no-unmatchable-anb-selector">lint/correctness/noUnmatchableAnbSelector</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">This selector will never match any elements.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a:nth-last-child(0n) &#123;&#125;<br />   <strong>   │ </strong>                 <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Avoid using An+B selectors that always evaluate to 0.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">For more details, see </span><span style="color: lightgreen;"><a href="https://www.w3.org/TR/css-syntax-3/#anb-microsyntax">the official spec for An+B selectors</a></span><span style="color: lightgreen;">.</span><br />  <br /></code></pre>

```css
a:nth-of-type(0n+0) {}
```

<pre class="language-text"><code class="language-text">code-block.css:1:15 <a href="https://biomejs.dev/linter/rules/no-unmatchable-anb-selector">lint/correctness/noUnmatchableAnbSelector</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">This selector will never match any elements.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a:nth-of-type(0n+0) &#123;&#125;<br />   <strong>   │ </strong>              <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Avoid using An+B selectors that always evaluate to 0.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">For more details, see </span><span style="color: lightgreen;"><a href="https://www.w3.org/TR/css-syntax-3/#anb-microsyntax">the official spec for An+B selectors</a></span><span style="color: lightgreen;">.</span><br />  <br /></code></pre>

```css
a:nth-last-of-type(0 of a) {}
```

<pre class="language-text"><code class="language-text">code-block.css:1:20 <a href="https://biomejs.dev/linter/rules/no-unmatchable-anb-selector">lint/correctness/noUnmatchableAnbSelector</a> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Tomato;">✖</span></strong> <span style="color: Tomato;">This selector will never match any elements.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>a:nth-last-of-type(0 of a) &#123;&#125;<br />   <strong>   │ </strong>                   <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Avoid using An+B selectors that always evaluate to 0.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">For more details, see </span><span style="color: lightgreen;"><a href="https://www.w3.org/TR/css-syntax-3/#anb-microsyntax">the official spec for An+B selectors</a></span><span style="color: lightgreen;">.</span><br />  <br /></code></pre>

### Valid

```css
a:nth-child(1) {}
```

```css
a:nth-last-child(1n) {}
```

```css
a:nth-of-type(1n+0) {}
```

```css
a:nth-last-of-type(1 of a) {}
```

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_css_analyze/src/lint/correctness/no_unmatchable_anb_selector.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_css_analyze/tests/specs/correctness/noUnmatchableAnbSelector)

</TabItem>
</Tabs>