::grammar-error CSS pseudo-element

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The ::grammar-error CSS pseudo-element represents a text segment which the user agent has flagged as grammatically incorrect.

The ::grammar-error pseudo-element follows a special inheritance model common to all highlight pseudo-elements. For more details on how this inheritance works, see the Highlight pseudo-elements inheritance section.

Allowable properties

Only a small subset of CSS properties can be used in a rule with ::grammar-error in its selector:

Syntax

css
::grammar-error {
  /* ... */
}

Examples

Basic document grammar check

In this example, eventual supporting browsers should highlight any flagged grammatical errors with the styles shown.

HTML

html
<p contenteditable spellcheck="true">
  My friends is coming to the party tonight.
</p>

CSS

css
::grammar-error {
  text-decoration: underline red;
  color: red;
}

Result

Specifications

Specification
CSS Pseudo-Elements Module Level 4
# selectordef-grammar-error

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
::grammar-error
Chrome – Full support
Chrome 121 (Release date: 2024-01-23)
footnote Full support
Edge – Full support
Edge 121 (Release date: 2024-01-25)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 107 (Release date: 2024-02-07)
footnote Full support
Safari – Full support
Safari 17.4 (Release date: 2024-03-05)
footnote Full support
Chrome Android – Full support
Chrome Android 121 (Release date: 2024-01-23)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 81 (Release date: 2024-03-14)
footnote Full support
Safari on iOS – Full support
Safari on iOS 17.4 (Release date: 2024-03-05)
footnote Full support
Samsung Internet – Full support
Samsung Internet 25 (Release date: 2024-04-24)
footnote Full support
WebView Android – Full support
WebView Android 121 (Release date: 2024-01-23)
footnote Full support
WebView on iOS – Full support
WebView on iOS 17.4 (Release date: 2024-03-05)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

See also