• Skip to main content
  • Skip to search
  • Skip to select language
MDN Web Docs
  • References
    • Overview / Web Technology

      Web technology reference for developers

    • HTML

      Structure of content on the web

    • CSS

      Code used to describe document style

    • JavaScript

      General-purpose scripting language

    • HTTP

      Protocol for transmitting web resources

    • Web APIs

      Interfaces for building web applications

    • Web Extensions

      Developing extensions for web browsers

    • Accessibility

      Build web projects usable for all

    • Web Technology

      Web technology reference for developers

  • Learn
    • Overview / MDN Learning Area

      Learn web development

    • MDN Learning Area

      Learn web development

    • HTML

      Learn to structure web content with HTML

    • CSS

      Learn to style content using CSS

    • JavaScript

      Learn to run scripts in the browser

    • Accessibility

      Learn to make the web accessible to all

  • Plus
    • Overview

      A customized MDN experience

    • AI Help

      Get real-time assistance and support

    • Updates

      All browser compatibility updates at a glance

    • Documentation

      Learn how to use MDN Plus

    • FAQ

      Frequently asked questions about MDN Plus

  • Curriculum New
  • Blog
    • Playground

      Write, test and share your code

    • HTTP Observatory

      Scan a website for free

    • AI Help

      Get real-time assistance and support

  • Log in
  • Sign up for free
  1. References
  2. Web APIs
  3. CustomStateSet
  4. clear()
    • Deutsch

In this article

  • Syntax
  • Specifications
  • Browser compatibility
  1. Web Components
  2. CustomStateSet
  3. Instance properties
    1. size
  4. Instance methods
    1. add()
    2. clear()
    3. delete()
    4. entries()
    5. forEach()
    6. has()
    7. keys()
    8. values()
  5. Related pages for Web Components
    1. CustomElementRegistry
    2. Document.createElement()
    3. Element.attachShadow()
    4. Element.shadowRoot
    5. Element.slot
    6. ElementInternals
    7. Event.composed
    8. Event.composedPath
    9. HTMLElement.attachInternals()
    10. HTMLSlotElement
    11. HTMLTemplateElement
    12. Node.getRootNode()
    13. Node.isConnected
    14. ShadowRoot
    15. Window.customElements

In this article

  • Syntax
  • Specifications
  • Browser compatibility

CustomStateSet: clear() method

Baseline 2024
Newly available

Since May 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

  • Learn more
  • See full compatibility
  • Report feedback

The clear() method of the CustomStateSet interface removes all elements from the CustomStateSet object.

Syntax

js
clear()

Parameters

None.

Return value

Undefined.

Specifications

Specification
HTML
# custom-state-pseudo-class

Browser compatibility

Help improve MDN

Learn how to contribute.

This page was last modified on Mar 26, 2024 by MDN contributors.

View this page on GitHub • Report a problem with this content
MDN logo

Your blueprint for a better internet.

  • MDN on Bluesky
  • MDN on Mastodon
  • MDN on X (formerly Twitter)
  • MDN on GitHub
  • MDN Blog RSS Feed

MDN

  • About
  • Blog
  • Careers
  • Advertise with us

Support

  • Product help
  • Report an issue

Our communities

  • MDN Community
  • MDN Forum
  • MDN Chat

Developers

  • Web Technologies
  • Learn Web Development
  • MDN Plus
  • Hacks Blog
  • Website Privacy Notice
  • Cookies
  • Legal
  • Community Participation Guidelines

Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2025 by individual mozilla.org contributors. Content available under a Creative Commons license.