···22<h1>
33 FixCSS
44</h1>
55-CSS as it *should* have been designed.
55+CSS as it <em>should</em> have been designed.
66</div>
77<br/>
8899In the design of CSS, mistakes were made. In fact, quite a number. The CSS Working Group says as much, having published an [Incomplete List of Mistakes in the Design of CSS](https://wiki.csswg.org/ideas/mistakes/).
10101111-This library rectifies these failings, and allows writing CSS the way it _should_ have been designed. FixCSS automatically converts corrected property names, values, selectors, and syntax, as an illustration of what should have been. It also fixes newer syntax compromised by trying to maintain consistency with previous mistakes.
1111+This library rectifies these failings and allows writing CSS the way it _should_ have been designed. FixCSS automatically converts corrected property names, values, selectors, and syntax, as an illustration of what should have been. It also fixes newer syntax compromised by trying to maintain consistency with previous mistakes.
12121313## Usage
1414···2525### Build-time
26262727```bash
2828-# CLI
2828+# CLI:
2929node fixcss-cli.js styles.css -o styles.fixed.css
30303131-# Or programmatically
3131+# Or programmatically:
3232npm install fixcss
3333```
3434···50505151```js
5252const out = fixCSS.fixCSS(".box { corner-radius: 10px; }");
5353-// → '.box { border-radius: 10px; }'
5353+// -> '.box { border-radius: 10px; }'
5454```
55555656**Options:**
57575858-- `fixShorthandDefaults` (default: `true`) — Single-value `background-size` duplicates to both axes, single-value `translate()` duplicates
5959-- `fixAxisOrder` (default: `true`) — Swap vertical-first axis order to horizontal-first for `background-position` and `border-spacing`
6060-- `fixSelectorCombinators` (default: `true`) — Convert `>>` → ` ` and `++` → `~`
5858+- `fixShorthandDefaults` (default: `true`) - Single-value `background-size` duplicates to both axes, single-value `translate()` duplicates
5959+- `fixAxisOrder` (default: `true`) - Swap vertical-first axis order to horizontal-first for `background-position` and `border-spacing`
6060+- `fixSelectorCombinators` (default: `true`) - Convert `>>` → ` ` and `++` → `~`
61616262#### `fixCSS.convertCCW(css)`
63636464-Convert CCW-ordered 4-value shorthands to CW (see mistake #11). This fix is opt-in, due to just being numbers and there unable to be auto-detected.
6464+Convert CCW-ordered 4-value shorthands to CW (see mistake #11). This fix is opt-in due to just being numbers which cannot be auto-detected.
65656666```js
6767-// CCW: top, left, bottom, right → CW: top, right, bottom, left
6767+// CCW: top, left, bottom, right -> CW: top, right, bottom, left
6868fixCSS.convertCCW(".x { margin: 10px 20px 30px 40px; }");
6969-// → '.x { margin: 10px 40px 30px 20px; }'
6969+// -> '.x { margin: 10px 40px 30px 20px; }'
7070```
71717272#### `fixCSS.convertProperties(css)`
···107107node fixcss-cli.js input.css -o output.css --ccw --no-axis
108108```
109109110110-| Flag | Description |
111111-| --------------------- | ---------------------------------- |
112112-| `-o, --output <file>` | Write output to file |
113113-| `-w, --watch` | Watch input file for changes |
114114-| `--stdin` | Read from stdin |
115115-| `--no-shorthand` | Don't fix shorthand defaults |
116116-| `--no-axis` | Don't fix axis order |
117117-| `--no-combinators` | Don't fix selector combinators |
118118-| `--ccw` | Enable CCW→CW shorthand conversion |
119119-| `-h, --help` | Show help |
110110+| Flag | Description |
111111+| --------------------- | ----------------------------------- |
112112+| `-o, --output <file>` | Write output to file |
113113+| `-w, --watch` | Watch input file for changes |
114114+| `--stdin` | Read from stdin |
115115+| `--no-shorthand` | Don't fix shorthand defaults |
116116+| `--no-axis` | Don't fix axis order |
117117+| `--no-combinators` | Don't fix selector combinators |
118118+| `--ccw` | Enable CCW->CW shorthand conversion |
119119+| `-h, --help` | Show help |
120120121121## See Also
122122