> For the complete documentation index, see [llms.txt](https://bryan-guner.gitbook.io/my-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bryan-guner.gitbook.io/my-docs/redux/repos/examples/real-world/node_modules/css-blank-pseudo.md).

# CSS Blank Pseudo

[![NPM Version](https://img.shields.io/npm/v/css-blank-pseudo.svg)](https://www.npmjs.com/package/css-blank-pseudo) [![Build Status](https://img.shields.io/travis/csstools/css-blank-pseudo/master.svg)](https://travis-ci.org/csstools/css-blank-pseudo) [![Support Chat](https://img.shields.io/badge/support-chat-blue.svg)](https://gitter.im/postcss/postcss)

[CSS Blank Pseudo](https://github.com/csstools/css-blank-pseudo) lets you style form elements when they are empty, following the [Selectors Level 4](https://drafts.csswg.org/selectors-4/#blank) specification.

```css
input {
  /* style an input */
}

input:blank {
  /* style an input without a value */
}
```

## Usage

From the command line, transform CSS files that use `:blank` selectors:

```bash
npx css-blank-pseudo SOURCE.css TRANSFORMED.css
```

Next, use your transformed CSS with this script:

```html
<link rel="stylesheet" href="TRANSFORMED.css">
<script src="https://unpkg.com/css-blank-pseudo/browser"></script>
<script>cssBlankPseudo(document)</script>
```

That’s it. The script is 509 bytes and works in all browsers.

***

If you support Internet Explorer 11, use the **browser legacy** script, which is 671 bytes:

```html
<link rel="stylesheet" href="TRANSFORMED.css">
<script src="https://unpkg.com/css-blank-pseudo/browser-legacy"></script>
<script>cssBlankPseudo(document)</script>
```

## How it works

The [PostCSS plugin](https://github.com/bgoonz/Learning-Redux/blob/master/repos/examples/real-world/node_modules/css-blank-pseudo/README-POSTCSS.md) clones rules containing `:blank`, replacing them with an alternative `[blank]` selector.

```css
input:blank {
  background-color: yellow;
}

/* becomes */

input[blank] {
  background-color: yellow;
}

input:blank {
  background-color: yellow;
}
```

Next, the [JavaScript library](https://github.com/bgoonz/Learning-Redux/blob/master/repos/examples/real-world/node_modules/css-blank-pseudo/README-BROWSER.md) adds a `blank` attribute to elements otherwise matching `:blank` natively.

```html
<input value="" blank>
<input value="This element has a value">
```
