Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

::spelling-error — styling spelling errors

The ::spelling-error pseudo-element styles text portions the browser flags as misspelled; it does not perform spellchecking itself.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

::spelling-error { /* highlight styles */ }
.editor::spelling-error { text-decoration: underline wavy red; }

::spelling-error represents a text portion the browser flags as misspelled, not the entire element. In contrast, ::grammar-error represents grammatical errors.

This highlight pseudo-element accepts a restricted set of properties, including color, background-color, and text-decoration, but not layout properties such as margin. The rule .editor::spelling-error scopes styling to text in .editor elements.

The example specifies a red wavy underline for text flagged as misspelled. Detection depends on the browser, language, and user dictionary. Even if the browser detects a spelling error, there may be no visible change because its default underline can look the same. The specification requires protection against exposing dictionary contents; do not treat this selector as an interface for reading detected errors.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Spelling highlight</title>
<style>
  .editor::spelling-error {
    text-decoration: underline wavy red;
  }
</style>
<p class="editor" contenteditable="true" spellcheck="true">This is a speling example.</p>
</html>

Result

This is a speling example.

The isolated browser check only verified that the text in `body` matched the expected output. It did not verify whether the browser detected a spelling error or applied the underline style.

Sources