Irina Glushko 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
..
CHANGELOG.md 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
LICENSE.md 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
README.md 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
browser-legacy.js 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
browser.js 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
cli.js 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
index.js 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
index.js.map 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
index.mjs 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
index.mjs.map 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
legacy.js 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
legacy.js.map 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
legacy.mjs 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
legacy.mjs.map 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
package.json 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
postcss.js 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
postcss.js.map 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
postcss.mjs 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos
postcss.mjs.map 2389e7160b HW1 done %!s(int64=3) %!d(string=hai) anos

README.md

CSS Blank Pseudo

NPM Version Build Status Support Chat

CSS Blank Pseudo lets you style form elements when they are empty, following the Selectors Level 4 specification.

input {
  /* style an input */
}

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

Usage

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

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

Next, use your transformed CSS with this script:

<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:

<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 clones rules containing :blank, replacing them with an alternative [blank] selector.

input:blank {
  background-color: yellow;
}

/* becomes */

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

input:blank {
  background-color: yellow;
}

Next, the JavaScript library adds a blank attribute to elements otherwise matching :blank natively.

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