# 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">
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bryan-guner.gitbook.io/my-docs/redux/repos/examples/real-world/node_modules/css-blank-pseudo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
