# CSS: “font-size”: “revert” is not a “font-size” value.

> Canonical HTML version: https://rocketvalidator.com/html-validation/css-font-size-revert-is-not-a-font-size-value
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `revert` keyword is one of the CSS-wide keywords defined in the CSS Cascading and Inheritance specification (along with `initial`, `inherit`, and `unset`). These keywords are valid values for every CSS property. When applied, `revert` rolls back the cascade to the value the property would have had if no author-level styles were applied — effectively reverting to the browser's default stylesheet (or the user stylesheet, if one exists).

Older versions of the Nu HTML Checker (the engine behind the W3C HTML Validator) did not fully recognize `revert` as a valid CSS-wide keyword for all properties, which caused this false positive. This has been fixed in newer versions of the validator. If you're using a local or outdated instance of the validator, updating to the latest version should resolve the issue.

Since this is a validator bug rather than a code issue, you have a few options: ignore the warning, update your validator, or use an alternative approach if you need a clean validation report. For example, you could use `unset` instead, which behaves similarly in many cases (though not identically — `unset` reverts to the inherited or initial value, while `revert` reverts to the user-agent default).

## Examples

### Code that triggers the false positive

This inline style uses `revert` on `font-size`, which is perfectly valid CSS but may trigger the validator warning:

```html
<p style="font-size: revert;">This paragraph uses the browser's default font size.</p>
```

### Workaround using `unset`

If you need to pass validation on an older validator instance, `unset` can serve as a partial substitute. Note that `unset` behaves differently from `revert` — it resets to the `inherited` value (for inherited properties like `font-size`) rather than the user-agent default:

```html
<p style="font-size: unset;">This paragraph inherits the font size from its parent.</p>
```

### Using `revert` in a stylesheet

The `revert` keyword is especially useful when you want to undo author styles for specific elements. This is valid CSS and should not produce errors in up-to-date validators:

```html
<style>
  p {
    font-size: 2rem;
  }
  .default-size {
    font-size: revert;
  }
</style>
<p>This paragraph has a 2rem font size.</p>
<p class="default-size">This paragraph reverts to the browser default font size.</p>
```

### All CSS-wide keywords

For reference, all of these CSS-wide keywords are valid for `font-size` and every other CSS property:

```html
<div style="font-size: initial;">Uses the property's initial value</div>
<div style="font-size: inherit;">Inherits from the parent element</div>
<div style="font-size: unset;">Resets to inherited or initial value</div>
<div style="font-size: revert;">Reverts to the user-agent default</div>
<div style="font-size: revert-layer;">Reverts to the previous cascade layer</div>
```
