::spelling-error CSS Pseudo Element
Description
The ::spelling-error pseudo-element in CSS is designed to target text segments that a browser identifies as misspelled according to its spell-checking engine. When applied, it allows developers to style these sections of text differently, providing a visual cue to users that the content may contain typographical errors. This can be particularly useful in rich text editors, content management systems, or any user-facing input fields where spelling feedback is desirable.
Unlike standard elements, ::spelling-error does not affect the document structure; it purely provides a styling hook for text that fails spell-check validation. This pseudo-element can be used in conjunction with ::selection or ::marker pseudo-elements to create a more interactive or visually informative text editing experience.
Styling this pseudo-element typically involves visual properties such as text-decoration, color, and background-color. For instance, a common approach is to underline misspelled words with a wavy red line, mimicking the behavior found in many word processors and web editors.
Here is an example of how ::spelling-error can be used in CSS and HTML:
<p contenteditable="true">
This is an exampel of a sentense with speling errors.
</p>
p::spelling-error {
text-decoration: underline wavy red;
color: darkred;
background-color: #ffe6e6;
}
In this example, any misspelled words inside the editable <p> element are highlighted with a red wavy underline and a light red background. Note that the effectiveness of this pseudo-element depends on the browser’s spell-check functionality being enabled for the content.
The ::spelling-error pseudo-element provides a user-friendly way to visually flag errors without modifying the underlying content, complementing other interactive pseudo-elements and properties in modern CSS workflows.
Syntax
::spelling-error {
/* ... */
}
Example
Browser Support
The following information will show you the current browser support for the CSS ::spelling-error pseudo element. Hover over a browser icon to see the version that first introduced support for this CSS psuedo element.
This psuedo element is supported in some modern browsers, but not all.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 31st December 2025
