files/en-us/web/api/highlight/clear/index.md
{{APIRef("CSS Custom Highlight API")}}
The clear() method of the {{domxref("Highlight")}} interface removes all the {{domxref("Range")}} objects from a Highlight object.
Highlight is a {{jsxref("Set")}}-like object, so this is similar to using {{jsxref("Set.clear()")}}.
clear()
None.
None ({{jsxref("undefined")}}).
The code snippet below shows how to create a new highlight with two ranges, and then clear it:
const highlight = new Highlight(range1, range2);
console.log(highlight.size); // 2
highlight.clear();
console.log(highlight.size); // 0
{{Specifications}}
{{Compat}}