Highlight: type property

Limited availability

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

The type property of the Highlight interface is an enumerated String used to specify the meaning of the highlight. This allows assistive technologies, such as screen readers, to include this meaning when exposing the highlight to users.

By default, a highlight object will have its type set to highlight, but you can change it to spelling-error or grammar-error.


The possible values of the type enumerated value are:


This is the default highlight type. It does not have any specific meaning.


Use this type when the highlight is used to emphasize misspelled content.


Use this type when the highlight is used to emphasize content that is grammatically incorrect.


const spellErrorRange = new Range();
spellErrorRange.setStart(textNode, 10);
spellErrorRange.setEnd(textNode, 20);

const spellErrorsHighlight = new Highlight(spellErrorRange);

spellErrorsHighlight.type = "spelling-error";


CSS Custom Highlight API Module Level 1
# enumdef-highlighttype

Browser compatibility

BCD tables only load in the browser

See also