🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 53 (from laksa051)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
3 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.1 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility
Last Crawled2026-04-09 00:25:56 (3 days ago)
First Indexed2023-04-17 05:24:51 (2 years ago)
HTTP Status Code200
Meta TitleElement: checkVisibility() method - Web APIs | MDN
Meta DescriptionThe checkVisibility() method of the Element interface checks whether the element is visible.
Meta Canonicalnull
Boilerpipe Text
Baseline 2024 Newly available Since March 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 checkVisibility() method of the Element interface checks whether the element is visible. The method returns false in either of the following situations: The element doesn't have an associated box, for example because the CSS display property is set to none or contents . The element is not being rendered because the element or an ancestor element sets the content-visibility property to hidden . The optional parameter enables additional checks to test for other interpretations of what "visible" means. For example, you can further check whether an element has an opacity of 0 , if the value of the element visibility property makes it invisible, or if the element content-visibility property has a value of auto and its rendering is currently being skipped. Syntax js checkVisibility(options) Parameters options Optional An object indicating additional checks to run. The possible options are: contentVisibilityAuto true to check if the element content-visibility property has (or inherits) the value auto , and it is currently skipping its rendering. false by default. opacityProperty true to check if the element opacity property has (or inherits) a value of 0 . false by default. visibilityProperty true to check if the element is invisible due to the value of its visibility property. false by default. checkOpacity A historic alias for opacityProperty . checkVisibilityCSS A historic alias for visibilityProperty . Return value false if any of the following conditions are met, otherwise true : The element doesn't have an associated box. The element content-visibility property has (or inherits) a value of hidden . opacityProperty (or checkOpacity ) is true and the element opacity property has (or inherits) a value of 0 . visibilityProperty (or checkVisibilityCSS ) is true and the element is invisible due to the value of its visibility property. contentVisibilityAuto is true , the content-visibility property has (or inherits) a value of auto , and element rendering is being skipped. Examples Test checkVisibility() with varied CSS The following example allows you to test how the result of checkVisibility() might change with different values for display , content-visibility , visibility , and opacity CSS properties. HTML The HTML defines a <select> element for the CSS properties that affect the results of checkVisibility() . The first (default selected) values should result in checkVisibility() returning true when applied to an element, while the other values affect the visibility. html <select id="css_display" name="css_display"> <option value="block" selected>display: block</option> <option value="none">display: none</option> <option value="contents">display: contents</option> </select> <select id="css_content_visibility" name="css_content_visibility"> <option value="visible" selected>content-visibility: visible</option> <option value="hidden">content-visibility: hidden</option> <option value="auto">content-visibility: auto</option> </select> <select id="css_opacity" name="css_opacity"> <option value="1" selected>opacity: 1</option> <option value="0">opacity: 0</option> </select> <select id="css_visibility" name="css_visibility"> <option value="visible" selected>visibility: visible</option> <option value="hidden">visibility: hidden</option> <option value="collapse">visibility: collapse</option> </select> Next we have a <pre> that is used to output the result of the checkVisibility() check when no options are passed in the parameter, and for each separate option value. At the end we have the element that will be tested (to which we will apply the selected CSS property values). html <pre id="output_result"></pre> <div id="test_element">The element to be checked for visibility.</div> CSS The CSS just highlights the element to be tested. css #test_element { border: solid; border-color: blue; } JavaScript The code below gets each of the <select> elements. The updateCSS() method is called on start and whenever the select elements change in order to apply the selected CSS to the target element, js const displayCssSelect = document.getElementById("css_display"); const contentVisibilityCssSelect = document.getElementById( "css_content_visibility", ); const displayCssOpacity = document.getElementById("css_opacity"); const displayCssVisibility = document.getElementById("css_visibility"); const outputResult = document.getElementById("output_result"); const elementToCheck = document.getElementById("test_element"); updateCSS(); const cssSelectors = document.querySelectorAll("select"); cssSelectors.forEach((select) => { select.addEventListener("change", (event) => { updateCSS(); }); }); function updateCSS() { // Apply selected CSS properties to target element elementToCheck.style.display = displayCssSelect.value; elementToCheck.style.contentVisibility = contentVisibilityCssSelect.value; elementToCheck.style.opacity = displayCssOpacity.value; elementToCheck.style.visibility = displayCssVisibility.value; // Call checkVisibility() on element using default and each of options const defaultVisibilityCheck = elementToCheck.checkVisibility(); const opacityVisibilityCheck = elementToCheck.checkVisibility({ opacityProperty: true, }); const cssVisibilityCheck = elementToCheck.checkVisibility({ visibilityProperty: true, }); const contentVisibilityAutoCheck = elementToCheck.checkVisibility({ contentVisibilityAuto: true, }); // Output the results of the tests outputResult.innerText = `Checks on element below (may be hidden): - Result of checkVisibility(): ${defaultVisibilityCheck} - Result of checkVisibility({opacityProperty: true}): ${opacityVisibilityCheck} - Result of checkVisibility({visibilityProperty: true}): ${cssVisibilityCheck} - Result of checkVisibility({contentVisibilityAuto: true}): ${contentVisibilityAutoCheck}`; } Result The results are shown below. If you change the selection the results will be applied to the test element (blue outline) and the results of the checkVisibility() for each setting should be displayed. So for example, if you set the opacity: 0 that test (only) should indicate false . However if you set display: none then all tests should return false . Specifications Specification CSSOM View Module # dom-element-checkvisibility Browser compatibility
Markdown
- [Skip to main content](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#content) - [Skip to search](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#search) HTML [HTML: Markup language](https://developer.mozilla.org/en-US/docs/Web/HTML) HTML reference - [Elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements) - [Global attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes) - [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes) - [See all…](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference "See all HTML references") HTML guides - [Responsive images](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Responsive_images) - [HTML cheatsheet](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Cheatsheet) - [Date & time formats](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Date_and_time_formats) - [See all…](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides "See all HTML guides") Markup languages - [SVG](https://developer.mozilla.org/en-US/docs/Web/SVG) - [MathML](https://developer.mozilla.org/en-US/docs/Web/MathML) - [XML](https://developer.mozilla.org/en-US/docs/Web/XML) CSS [CSS: Styling language](https://developer.mozilla.org/en-US/docs/Web/CSS) CSS reference - [Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties) - [Selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors) - [At-rules](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules) - [Values](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values) - [See all…](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference "See all CSS references") CSS guides - [Box model](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Box_model/Introduction) - [Animations](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Animations/Using) - [Flexbox](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Flexible_box_layout/Basic_concepts) - [Colors](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Colors/Applying_color) - [See all…](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides "See all CSS guides") Layout cookbook - [Column layouts](https://developer.mozilla.org/en-US/docs/Web/CSS/How_to/Layout_cookbook/Column_layouts) - [Centering an element](https://developer.mozilla.org/en-US/docs/Web/CSS/How_to/Layout_cookbook/Center_an_element) - [Card component](https://developer.mozilla.org/en-US/docs/Web/CSS/How_to/Layout_cookbook/Card) - [See all…](https://developer.mozilla.org/en-US/docs/Web/CSS/How_to/Layout_cookbook) JavaScriptJS [JavaScript: Scripting language](https://developer.mozilla.org/en-US/docs/Web/JavaScript) JS reference - [Standard built-in objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects) - [Expressions & operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators) - [Statements & declarations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements) - [Functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions) - [See all…](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference "See all JavaScript references") JS guides - [Control flow & error handing](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling) - [Loops and iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration) - [Working with objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_objects) - [Using classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_classes) - [See all…](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide "See all JavaScript guides") Web APIs [Web APIs: Programming interfaces](https://developer.mozilla.org/en-US/docs/Web/API) Web API reference - [File system API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API) - [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) - [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API) - [HTML DOM API](https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API) - [Push API](https://developer.mozilla.org/en-US/docs/Web/API/Push_API) - [Service worker API](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) - [See all…](https://developer.mozilla.org/en-US/docs/Web/API "See all Web API guides") Web API guides - [Using the Web animation API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API/Using_the_Web_Animations_API) - [Using the Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) - [Working with the History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API) - [Using the Web speech API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API/Using_the_Web_Speech_API) - [Using web workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) All [All web technology](https://developer.mozilla.org/en-US/docs/Web) Technologies - [Accessibility](https://developer.mozilla.org/en-US/docs/Web/Accessibility) - [HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP) - [URI](https://developer.mozilla.org/en-US/docs/Web/URI) - [Web extensions](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions) - [WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly) - [WebDriver](https://developer.mozilla.org/en-US/docs/Web/WebDriver) - [See all…](https://developer.mozilla.org/en-US/docs/Web "See all web technology references") Topics - [Media](https://developer.mozilla.org/en-US/docs/Web/Media) - [Performance](https://developer.mozilla.org/en-US/docs/Web/Performance) - [Privacy](https://developer.mozilla.org/en-US/docs/Web/Privacy) - [Security](https://developer.mozilla.org/en-US/docs/Web/Security) - [Progressive web apps](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps) Learn [Learn web development](https://developer.mozilla.org/en-US/docs/Learn_web_development) Frontend developer course - [Getting started modules](https://developer.mozilla.org/en-US/docs/Learn_web_development/Getting_started) - [Core modules](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core) - [MDN Curriculum](https://developer.mozilla.org/en-US/curriculum/) - [Check out the video course from Scrimba, our partner](https://scrimba.com/frontend-path-c0j?via=mdn-learn-navbar) Learn HTML - [Structuring content with HTML module](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Structuring_content) Learn CSS - [CSS styling basics module](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics) - [CSS layout module](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/CSS_layout) Learn JavaScript - [Dynamic scripting with JavaScript module](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting) Tools Discover our tools - [Playground](https://developer.mozilla.org/en-US/play) - [HTTP Observatory](https://developer.mozilla.org/en-US/observatory) - [Border-image generator](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Backgrounds_and_borders/Border-image_generator) - [Border-radius generator](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Backgrounds_and_borders/Border-radius_generator) - [Box-shadow generator](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Backgrounds_and_borders/Box-shadow_generator) - [Color format converter](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Colors/Color_format_converter) - [Color mixer](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Colors/Color_mixer) - [Shape generator](https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Shapes/Shape_generator) About Get to know MDN better - [About MDN](https://developer.mozilla.org/en-US/about) - [Advertise with us](https://developer.mozilla.org/en-US/advertising) - [Community](https://developer.mozilla.org/en-US/community) - [MDN on GitHub](https://github.com/mdn) [Blog](https://developer.mozilla.org/en-US/blog/) 1. [Web](https://developer.mozilla.org/en-US/docs/Web) 2. [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) 3. [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) 4. [checkVisibility()](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility) # Element: checkVisibility() method Baseline 2024 Newly available Since March 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers. - [Learn more](https://developer.mozilla.org/en-US/docs/Glossary/Baseline/Compatibility) - [See full compatibility](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility) - [Report feedback](https://survey.alchemer.com/s3/7634825/MDN-baseline-feedback?page=%2Fen-US%2Fdocs%2FWeb%2FAPI%2FElement%2FcheckVisibility&level=low) The **`checkVisibility()`** method of the [`Element`](https://developer.mozilla.org/en-US/docs/Web/API/Element) interface checks whether the element is visible. The method returns `false` in either of the following situations: - The element doesn't have an associated box, for example because the CSS [`display`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/display) property is set to [`none`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/display#none) or [`contents`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/display#contents). - The element is not being rendered because the element or an ancestor element sets the [`content-visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility) property to [`hidden`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility#hidden). The optional parameter enables additional checks to test for other interpretations of what "visible" means. For example, you can further check whether an element has an opacity of `0`, if the value of the element [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/visibility) property makes it invisible, or if the element [`content-visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility) property has a value of [`auto`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility#auto) and its rendering is currently being skipped. ## In this article - [Syntax](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#syntax) - [Examples](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#examples) - [Specifications](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#specifications) - [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility) ## [Syntax](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#syntax) js ``` checkVisibility(options) ``` ### [Parameters](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#parameters) [`options` Optional](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#options) An object indicating additional checks to run. The possible options are: [`contentVisibilityAuto`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#contentvisibilityauto) `true` to check if the element [`content-visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility) property has (or inherits) the value [`auto`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility#auto), and it is currently skipping its rendering. `false` by default. [`opacityProperty`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#opacityproperty) `true` to check if the element [`opacity`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/opacity) property has (or inherits) a value of `0`. `false` by default. [`visibilityProperty`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#visibilityproperty) `true` to check if the element is invisible due to the value of its [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/visibility) property. `false` by default. **Note:** Invisible elements include those that have [`visibility: hidden`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/visibility#hidden), and some element types that have [`visibility: collapse`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/visibility#collapse). [`checkOpacity`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#checkopacity) A historic alias for [`opacityProperty`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#opacityproperty). [`checkVisibilityCSS`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#checkvisibilitycss) A historic alias for [`visibilityProperty`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#visibilityproperty). ### [Return value](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#return_value) `false` if any of the following conditions are met, otherwise `true`: - The element doesn't have an associated box. - The element [`content-visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility) property has (or inherits) a value of [`hidden`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/visibility#hidden). - `opacityProperty` (or `checkOpacity`) is `true` and the element [`opacity`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/opacity) property has (or inherits) a value of `0`. - `visibilityProperty` (or `checkVisibilityCSS`) is `true` and the element is invisible due to the value of its [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/visibility) property. - `contentVisibilityAuto` is `true`, the [`content-visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility) property has (or inherits) a value of [`auto`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility#auto), and element rendering is being skipped. ## [Examples](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#examples) ### [Test checkVisibility() with varied CSS](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#test_checkvisibility_with_varied_css) The following example allows you to test how the result of `checkVisibility()` might change with different values for `display`, `content-visibility`, `visibility`, and `opacity` CSS properties. #### HTML The HTML defines a `<select>` element for the CSS properties that affect the results of `checkVisibility()`. The first (default selected) values should result in `checkVisibility()` returning `true` when applied to an element, while the other values affect the visibility. html ``` <select id="css_display" name="css_display"> <option value="block" selected>display: block</option> <option value="none">display: none</option> <option value="contents">display: contents</option> </select> <select id="css_content_visibility" name="css_content_visibility"> <option value="visible" selected>content-visibility: visible</option> <option value="hidden">content-visibility: hidden</option> <option value="auto">content-visibility: auto</option> </select> <select id="css_opacity" name="css_opacity"> <option value="1" selected>opacity: 1</option> <option value="0">opacity: 0</option> </select> <select id="css_visibility" name="css_visibility"> <option value="visible" selected>visibility: visible</option> <option value="hidden">visibility: hidden</option> <option value="collapse">visibility: collapse</option> </select> ``` Next we have a `<pre>` that is used to output the result of the `checkVisibility()` check when no options are passed in the parameter, and for each separate option value. At the end we have the element that will be tested (to which we will apply the selected CSS property values). html ``` <pre id="output_result"></pre> <div id="test_element">The element to be checked for visibility.</div> ``` #### CSS The CSS just highlights the element to be tested. css ``` #test_element { border: solid; border-color: blue; } ``` #### JavaScript The code below gets each of the `<select>` elements. The `updateCSS()` method is called on start and whenever the select elements change in order to apply the selected CSS to the target element, js ``` const displayCssSelect = document.getElementById("css_display"); const contentVisibilityCssSelect = document.getElementById( "css_content_visibility", ); const displayCssOpacity = document.getElementById("css_opacity"); const displayCssVisibility = document.getElementById("css_visibility"); const outputResult = document.getElementById("output_result"); const elementToCheck = document.getElementById("test_element"); updateCSS(); const cssSelectors = document.querySelectorAll("select"); cssSelectors.forEach((select) => { select.addEventListener("change", (event) => { updateCSS(); }); }); function updateCSS() { // Apply selected CSS properties to target element elementToCheck.style.display = displayCssSelect.value; elementToCheck.style.contentVisibility = contentVisibilityCssSelect.value; elementToCheck.style.opacity = displayCssOpacity.value; elementToCheck.style.visibility = displayCssVisibility.value; // Call checkVisibility() on element using default and each of options const defaultVisibilityCheck = elementToCheck.checkVisibility(); const opacityVisibilityCheck = elementToCheck.checkVisibility({ opacityProperty: true, }); const cssVisibilityCheck = elementToCheck.checkVisibility({ visibilityProperty: true, }); const contentVisibilityAutoCheck = elementToCheck.checkVisibility({ contentVisibilityAuto: true, }); // Output the results of the tests outputResult.innerText = `Checks on element below (may be hidden): - Result of checkVisibility(): ${defaultVisibilityCheck} - Result of checkVisibility({opacityProperty: true}): ${opacityVisibilityCheck} - Result of checkVisibility({visibilityProperty: true}): ${cssVisibilityCheck} - Result of checkVisibility({contentVisibilityAuto: true}): ${contentVisibilityAutoCheck}`; } ``` #### Result The results are shown below. If you change the selection the results will be applied to the test element (blue outline) and the results of the `checkVisibility()` for each setting should be displayed. So for example, if you set the `opacity: 0` that test (only) should indicate `false`. However if you set `display: none` then all tests should return `false`. ## [Specifications](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#specifications) | Specification | |---| | [CSSOM View Module \# dom-element-checkvisibility](https://drafts.csswg.org/cssom-view-1/#dom-element-checkvisibility) | ## [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility) ## Help improve MDN [Learn how to contribute](https://developer.mozilla.org/en-US/docs/MDN/Community/Getting_started) This page was last modified on Dec 17, 2025 by [MDN contributors](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility/contributors.txt). [View this page on GitHub](https://github.com/mdn/content/blob/main/files/en-us/web/api/element/checkvisibility/index.md?plain=1 "Folder: en-us/web/api/element/checkvisibility (Opens in a new tab)") • [Report a problem with this content](https://github.com/mdn/content/issues/new?template=page-report.yml&mdn-url=https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FAPI%2FElement%2FcheckVisibility&metadata=%3C%21--+Do+not+make+changes+below+this+line+--%3E%0A%3Cdetails%3E%0A%3Csummary%3EPage+report+details%3C%2Fsummary%3E%0A%0A*+Folder%3A+%60en-us%2Fweb%2Fapi%2Felement%2Fcheckvisibility%60%0A*+MDN+URL%3A+https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FAPI%2FElement%2FcheckVisibility%0A*+GitHub+URL%3A+https%3A%2F%2Fgithub.com%2Fmdn%2Fcontent%2Fblob%2Fmain%2Ffiles%2Fen-us%2Fweb%2Fapi%2Felement%2Fcheckvisibility%2Findex.md%0A*+Last+commit%3A+https%3A%2F%2Fgithub.com%2Fmdn%2Fcontent%2Fcommit%2F0c13af55e869cbc54830fd1a601fd05f60717375%0A*+Document+last+modified%3A+2025-12-17T16%3A01%3A14.000Z%0A%0A%3C%2Fdetails%3E "This will take you to GitHub to file a new issue.") 1. [Document Object Model (DOM)](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model) 2. [`Element`](https://developer.mozilla.org/en-US/docs/Web/API/Element) 3. Instance properties 1. [`ariaActiveDescendantElement`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaActiveDescendantElement) 2. [`ariaAtomic`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaAtomic) 3. [`ariaAutoComplete`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaAutoComplete) 4. [`ariaBrailleLabel`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaBrailleLabel) 5. [`ariaBrailleRoleDescription`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaBrailleRoleDescription) 6. [`ariaBusy`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaBusy) 7. [`ariaChecked`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaChecked) 8. [`ariaColCount`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaColCount) 9. [`ariaColIndex`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaColIndex) 10. [`ariaColIndexText`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaColIndexText) 11. [`ariaColSpan`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaColSpan) 12. [`ariaControlsElements`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaControlsElements) 13. [`ariaCurrent`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaCurrent) 14. [`ariaDescribedByElements`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaDescribedByElements) 15. [`ariaDescription`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaDescription) 16. [`ariaDetailsElements`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaDetailsElements) 17. [`ariaDisabled`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaDisabled) 18. [`ariaErrorMessageElements`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaErrorMessageElements) 19. [`ariaExpanded`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaExpanded) 20. [`ariaFlowToElements`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaFlowToElements) 21. [`ariaHasPopup`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaHasPopup) 22. [`ariaHidden`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaHidden) 23. [`ariaInvalid`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaInvalid) 24. [`ariaKeyShortcuts`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaKeyShortcuts) 25. [`ariaLabel`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaLabel) 26. [`ariaLabelledByElements`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaLabelledByElements) 27. [`ariaLevel`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaLevel) 28. [`ariaLive`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaLive) 29. [`ariaModal`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaModal) 30. [`ariaMultiLine`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaMultiLine) 31. [`ariaMultiSelectable`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaMultiSelectable) 32. [`ariaOrientation`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaOrientation) 33. [`ariaOwnsElements`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaOwnsElements) 34. [`ariaPlaceholder`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaPlaceholder) 35. [`ariaPosInSet`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaPosInSet) 36. [`ariaPressed`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaPressed) 37. [`ariaReadOnly`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaReadOnly) 38. [`ariaRelevant`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaRelevant) Non-standard 39. [`ariaRequired`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaRequired) 40. [`ariaRoleDescription`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaRoleDescription) 41. [`ariaRowCount`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaRowCount) 42. [`ariaRowIndex`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaRowIndex) 43. [`ariaRowIndexText`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaRowIndexText) 44. [`ariaRowSpan`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaRowSpan) 45. [`ariaSelected`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaSelected) 46. [`ariaSetSize`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaSetSize) 47. [`ariaSort`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaSort) 48. [`ariaValueMax`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaValueMax) 49. [`ariaValueMin`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaValueMin) 50. [`ariaValueNow`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaValueNow) 51. [`ariaValueText`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaValueText) 52. [`assignedSlot`](https://developer.mozilla.org/en-US/docs/Web/API/Element/assignedSlot) 53. [`attributes`](https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes) 54. [`childElementCount`](https://developer.mozilla.org/en-US/docs/Web/API/Element/childElementCount) 55. [`children`](https://developer.mozilla.org/en-US/docs/Web/API/Element/children) 56. [`classList`](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList) 57. [`className`](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) 58. [`clientHeight`](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight) 59. [`clientLeft`](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientLeft) 60. [`clientTop`](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop) 61. [`clientWidth`](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth) 62. [`currentCSSZoom`](https://developer.mozilla.org/en-US/docs/Web/API/Element/currentCSSZoom) 63. [`customElementRegistry`](https://developer.mozilla.org/en-US/docs/Web/API/Element/customElementRegistry) 64. [`elementTiming`](https://developer.mozilla.org/en-US/docs/Web/API/Element/elementTiming) Experimental 65. [`firstElementChild`](https://developer.mozilla.org/en-US/docs/Web/API/Element/firstElementChild) 66. [`id`](https://developer.mozilla.org/en-US/docs/Web/API/Element/id) 67. [`innerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML) 68. [`lastElementChild`](https://developer.mozilla.org/en-US/docs/Web/API/Element/lastElementChild) 69. [`localName`](https://developer.mozilla.org/en-US/docs/Web/API/Element/localName) 70. [`namespaceURI`](https://developer.mozilla.org/en-US/docs/Web/API/Element/namespaceURI) 71. [`nextElementSibling`](https://developer.mozilla.org/en-US/docs/Web/API/Element/nextElementSibling) 72. [`outerHTML`](https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML) 73. [`part`](https://developer.mozilla.org/en-US/docs/Web/API/Element/part) 74. [`prefix`](https://developer.mozilla.org/en-US/docs/Web/API/Element/prefix) 75. [`previousElementSibling`](https://developer.mozilla.org/en-US/docs/Web/API/Element/previousElementSibling) 76. [`role`](https://developer.mozilla.org/en-US/docs/Web/API/Element/role) 77. [`scrollHeight`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight) 78. [`scrollLeft`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft) 79. [`scrollLeftMax`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeftMax) Non-standard 80. [`scrollTop`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop) 81. [`scrollTopMax`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTopMax) Non-standard 82. [`scrollWidth`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth) 83. [`shadowRoot`](https://developer.mozilla.org/en-US/docs/Web/API/Element/shadowRoot) 84. [`slot`](https://developer.mozilla.org/en-US/docs/Web/API/Element/slot) 85. [`tagName`](https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName) 4. Instance methods 1. [`after()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/after) 2. [`animate()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/animate) 3. [`append()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/append) 4. [`ariaNotify()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaNotify) 5. [`attachShadow()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow) 6. [`before()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/before) 7. *[`checkVisibility()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility)* 8. [`closest()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest) 9. [`computedStyleMap()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/computedStyleMap) 10. [`getAnimations()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations) 11. [`getAttribute()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute) 12. [`getAttributeNames()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames) 13. [`getAttributeNode()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNode) 14. [`getAttributeNodeNS()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNodeNS) 15. [`getAttributeNS()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNS) 16. [`getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) 17. [`getClientRects()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getClientRects) 18. [`getElementsByClassName()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName) 19. [`getElementsByTagName()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName) 20. [`getElementsByTagNameNS()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagNameNS) 21. [`getHTML()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getHTML) 22. [`hasAttribute()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute) 23. [`hasAttributeNS()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributeNS) 24. [`hasAttributes()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttributes) 25. [`hasPointerCapture()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/hasPointerCapture) 26. [`insertAdjacentElement()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentElement) 27. [`insertAdjacentHTML()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML) 28. [`insertAdjacentText()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentText) 29. [`matches()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/matches) 30. [`moveBefore()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/moveBefore) 31. [`prepend()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend) 32. [`querySelector()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector) 33. [`querySelectorAll()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll) 34. [`releasePointerCapture()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/releasePointerCapture) 35. [`remove()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/remove) 36. [`removeAttribute()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute) 37. [`removeAttributeNode()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttributeNode) 38. [`removeAttributeNS()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttributeNS) 39. [`replaceChildren()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren) 40. [`replaceWith()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceWith) 41. [`requestFullscreen()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullscreen) 42. [`requestPointerLock()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestPointerLock) 43. [`scroll()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll) 44. [`scrollBy()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollBy) 45. [`scrollIntoView()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) 46. [`scrollIntoViewIfNeeded()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded) Non-standard 47. [`scrollTo()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo) 48. [`setAttribute()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute) 49. [`setAttributeNode()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttributeNode) 50. [`setAttributeNodeNS()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttributeNodeNS) 51. [`setAttributeNS()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttributeNS) 52. [`setCapture()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/setCapture) Non-standard Deprecated 53. [`setHTML()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/setHTML) 54. [`setHTMLUnsafe()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/setHTMLUnsafe) 55. [`setPointerCapture()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture) 56. [`toggleAttribute()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/toggleAttribute) 5. Events 1. [`afterscriptexecute`](https://developer.mozilla.org/en-US/docs/Web/API/Element/afterscriptexecute_event) Non-standard Deprecated 2. [`animationcancel`](https://developer.mozilla.org/en-US/docs/Web/API/Element/animationcancel_event) 3. [`animationend`](https://developer.mozilla.org/en-US/docs/Web/API/Element/animationend_event) 4. [`animationiteration`](https://developer.mozilla.org/en-US/docs/Web/API/Element/animationiteration_event) 5. [`animationstart`](https://developer.mozilla.org/en-US/docs/Web/API/Element/animationstart_event) 6. [`auxclick`](https://developer.mozilla.org/en-US/docs/Web/API/Element/auxclick_event) 7. [`beforeinput`](https://developer.mozilla.org/en-US/docs/Web/API/Element/beforeinput_event) 8. [`beforematch`](https://developer.mozilla.org/en-US/docs/Web/API/Element/beforematch_event) 9. [`beforescriptexecute`](https://developer.mozilla.org/en-US/docs/Web/API/Element/beforescriptexecute_event) Non-standard Deprecated 10. [`beforexrselect`](https://developer.mozilla.org/en-US/docs/Web/API/Element/beforexrselect_event) Experimental 11. [`blur`](https://developer.mozilla.org/en-US/docs/Web/API/Element/blur_event) 12. [`click`](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event) 13. [`compositionend`](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionend_event) 14. [`compositionstart`](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event) 15. [`compositionupdate`](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionupdate_event) 16. [`contentvisibilityautostatechange`](https://developer.mozilla.org/en-US/docs/Web/API/Element/contentvisibilityautostatechange_event) 17. [`contextmenu`](https://developer.mozilla.org/en-US/docs/Web/API/Element/contextmenu_event) 18. [`copy`](https://developer.mozilla.org/en-US/docs/Web/API/Element/copy_event) 19. [`cut`](https://developer.mozilla.org/en-US/docs/Web/API/Element/cut_event) 20. [`dblclick`](https://developer.mozilla.org/en-US/docs/Web/API/Element/dblclick_event) 21. [`DOMActivate`](https://developer.mozilla.org/en-US/docs/Web/API/Element/DOMActivate_event) Deprecated 22. [`DOMMouseScroll`](https://developer.mozilla.org/en-US/docs/Web/API/Element/DOMMouseScroll_event) Non-standard Deprecated 23. [`focus`](https://developer.mozilla.org/en-US/docs/Web/API/Element/focus_event) 24. [`focusin`](https://developer.mozilla.org/en-US/docs/Web/API/Element/focusin_event) 25. [`focusout`](https://developer.mozilla.org/en-US/docs/Web/API/Element/focusout_event) 26. [`fullscreenchange`](https://developer.mozilla.org/en-US/docs/Web/API/Element/fullscreenchange_event) 27. [`fullscreenerror`](https://developer.mozilla.org/en-US/docs/Web/API/Element/fullscreenerror_event) 28. [`gesturechange`](https://developer.mozilla.org/en-US/docs/Web/API/Element/gesturechange_event) Non-standard 29. [`gestureend`](https://developer.mozilla.org/en-US/docs/Web/API/Element/gestureend_event) Non-standard 30. [`gesturestart`](https://developer.mozilla.org/en-US/docs/Web/API/Element/gesturestart_event) Non-standard 31. [`gotpointercapture`](https://developer.mozilla.org/en-US/docs/Web/API/Element/gotpointercapture_event) 32. [`input`](https://developer.mozilla.org/en-US/docs/Web/API/Element/input_event) 33. [`keydown`](https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event) 34. [`keypress`](https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event) Deprecated 35. [`keyup`](https://developer.mozilla.org/en-US/docs/Web/API/Element/keyup_event) 36. [`lostpointercapture`](https://developer.mozilla.org/en-US/docs/Web/API/Element/lostpointercapture_event) 37. [`mousedown`](https://developer.mozilla.org/en-US/docs/Web/API/Element/mousedown_event) 38. [`mouseenter`](https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseenter_event) 39. [`mouseleave`](https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseleave_event) 40. [`mousemove`](https://developer.mozilla.org/en-US/docs/Web/API/Element/mousemove_event) 41. [`mouseout`](https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseout_event) 42. [`mouseover`](https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseover_event) 43. [`mouseup`](https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseup_event) 44. [`mousewheel`](https://developer.mozilla.org/en-US/docs/Web/API/Element/mousewheel_event) Non-standard Deprecated 45. [`MozMousePixelScroll`](https://developer.mozilla.org/en-US/docs/Web/API/Element/MozMousePixelScroll_event) Non-standard Deprecated 46. [`paste`](https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event) 47. [`pointercancel`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointercancel_event) 48. [`pointerdown`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerdown_event) 49. [`pointerenter`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerenter_event) 50. [`pointerleave`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerleave_event) 51. [`pointermove`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointermove_event) 52. [`pointerout`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerout_event) 53. [`pointerover`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerover_event) 54. [`pointerrawupdate`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerrawupdate_event) 55. [`pointerup`](https://developer.mozilla.org/en-US/docs/Web/API/Element/pointerup_event) 56. [`scroll`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll_event) 57. [`scrollend`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollend_event) 58. [`scrollsnapchange`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollsnapchange_event) Experimental 59. [`scrollsnapchanging`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollsnapchanging_event) Experimental 60. [`securitypolicyviolation`](https://developer.mozilla.org/en-US/docs/Web/API/Element/securitypolicyviolation_event) 61. [`touchcancel`](https://developer.mozilla.org/en-US/docs/Web/API/Element/touchcancel_event) 62. [`touchend`](https://developer.mozilla.org/en-US/docs/Web/API/Element/touchend_event) 63. [`touchmove`](https://developer.mozilla.org/en-US/docs/Web/API/Element/touchmove_event) 64. [`touchstart`](https://developer.mozilla.org/en-US/docs/Web/API/Element/touchstart_event) 65. [`transitioncancel`](https://developer.mozilla.org/en-US/docs/Web/API/Element/transitioncancel_event) 66. [`transitionend`](https://developer.mozilla.org/en-US/docs/Web/API/Element/transitionend_event) 67. [`transitionrun`](https://developer.mozilla.org/en-US/docs/Web/API/Element/transitionrun_event) 68. [`transitionstart`](https://developer.mozilla.org/en-US/docs/Web/API/Element/transitionstart_event) 69. [`webkitmouseforcechanged`](https://developer.mozilla.org/en-US/docs/Web/API/Element/webkitmouseforcechanged_event) Non-standard 70. [`webkitmouseforcedown`](https://developer.mozilla.org/en-US/docs/Web/API/Element/webkitmouseforcedown_event) Non-standard 71. [`webkitmouseforceup`](https://developer.mozilla.org/en-US/docs/Web/API/Element/webkitmouseforceup_event) Non-standard 72. [`webkitmouseforcewillbegin`](https://developer.mozilla.org/en-US/docs/Web/API/Element/webkitmouseforcewillbegin_event) Non-standard 73. [`wheel`](https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event) 6. Inheritance 1. [`Node`](https://developer.mozilla.org/en-US/docs/Web/API/Node) 2. [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) 7. Related pages for DOM 1. [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) 2. [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) 3. [`AbstractRange`](https://developer.mozilla.org/en-US/docs/Web/API/AbstractRange) 4. [`Attr`](https://developer.mozilla.org/en-US/docs/Web/API/Attr) 5. [`CDATASection`](https://developer.mozilla.org/en-US/docs/Web/API/CDATASection) 6. [`CharacterData`](https://developer.mozilla.org/en-US/docs/Web/API/CharacterData) 7. [`Comment`](https://developer.mozilla.org/en-US/docs/Web/API/Comment) 8. [`CustomEvent`](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) 9. [`DOMError`](https://developer.mozilla.org/en-US/docs/Web/API/DOMError) Deprecated 10. [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) 11. [`DOMImplementation`](https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation) 12. [`DOMParser`](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser) 13. [`DOMTokenList`](https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList) 14. [`Document`](https://developer.mozilla.org/en-US/docs/Web/API/Document) 15. [`DocumentFragment`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment) 16. [`DocumentType`](https://developer.mozilla.org/en-US/docs/Web/API/DocumentType) 17. [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) 18. [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) 19. [`HTMLCollection`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection) 20. [`MutationObserver`](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) 21. [`MutationRecord`](https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord) 22. [`NamedNodeMap`](https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap) 23. [`Node`](https://developer.mozilla.org/en-US/docs/Web/API/Node) 24. [`NodeIterator`](https://developer.mozilla.org/en-US/docs/Web/API/NodeIterator) 25. [`NodeList`](https://developer.mozilla.org/en-US/docs/Web/API/NodeList) 26. [`ProcessingInstruction`](https://developer.mozilla.org/en-US/docs/Web/API/ProcessingInstruction) 27. [`QuotaExceededError`](https://developer.mozilla.org/en-US/docs/Web/API/QuotaExceededError) Experimental 28. [`Range`](https://developer.mozilla.org/en-US/docs/Web/API/Range) 29. [`ShadowRoot`](https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot) 30. [`StaticRange`](https://developer.mozilla.org/en-US/docs/Web/API/StaticRange) 31. [`Text`](https://developer.mozilla.org/en-US/docs/Web/API/Text) 32. [`TreeWalker`](https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker) 33. [`XMLDocument`](https://developer.mozilla.org/en-US/docs/Web/API/XMLDocument) 34. [`XPathEvaluator`](https://developer.mozilla.org/en-US/docs/Web/API/XPathEvaluator) 35. [`XPathExpression`](https://developer.mozilla.org/en-US/docs/Web/API/XPathExpression) 36. [`XPathResult`](https://developer.mozilla.org/en-US/docs/Web/API/XPathResult) 37. [`XSLTProcessor`](https://developer.mozilla.org/en-US/docs/Web/API/XSLTProcessor) 8. Guides 1. [Anatomy of the DOM](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Anatomy_of_the_DOM) 2. [Attribute reflection](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Reflected_attributes) 3. [Selection and traversal on the DOM tree](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Selection_and_traversal_on_the_DOM_tree) 4. [Building and updating the DOM tree](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Building_and_updating_the_DOM_tree) 5. [Working with events](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Events) Your blueprint for a better internet. MDN - [About](https://developer.mozilla.org/en-US/about) - [Blog](https://developer.mozilla.org/en-US/blog/) - [Mozilla careers](https://www.mozilla.org/en-US/careers/listings/) - [Advertise with us](https://developer.mozilla.org/en-US/advertising) - [MDN Plus](https://developer.mozilla.org/en-US/plus) - [Product help](https://support.mozilla.org/products/mdn-plus) Contribute - [MDN Community](https://developer.mozilla.org/en-US/community) - [Community resources](https://developer.mozilla.org/en-US/docs/MDN/Community) - [Writing guidelines](https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines) - [MDN Discord](https://developer.mozilla.org/discord) - [MDN on GitHub](https://github.com/mdn) Developers - [Web technologies](https://developer.mozilla.org/en-US/docs/Web) - [Learn web development](https://developer.mozilla.org/en-US/docs/Learn_web_development) - [Guides](https://developer.mozilla.org/en-US/docs/MDN/Guides) - [Tutorials](https://developer.mozilla.org/en-US/docs/MDN/Tutorials) - [Glossary](https://developer.mozilla.org/en-US/docs/Glossary) - [Hacks blog](https://hacks.mozilla.org/) - [Website Privacy Notice](https://www.mozilla.org/privacy/websites/) - [Telemetry Settings](https://www.mozilla.org/en-US/privacy/websites/data-preferences/) - [Legal](https://www.mozilla.org/about/legal/terms/mozilla) - [Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/) Visit [Mozilla Corporation’s](https://www.mozilla.org/) not-for-profit parent, the [Mozilla Foundation](https://foundation.mozilla.org/). Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under [a Creative Commons license](https://developer.mozilla.org/docs/MDN/Writing_guidelines/Attrib_copyright_license).
Readable Markdown
Baseline 2024 Newly available Since March 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers. - [Learn more](https://developer.mozilla.org/en-US/docs/Glossary/Baseline/Compatibility) - [See full compatibility](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility) - [Report feedback](https://survey.alchemer.com/s3/7634825/MDN-baseline-feedback?page=%2Fen-US%2Fdocs%2FWeb%2FAPI%2FElement%2FcheckVisibility&level=low) The **`checkVisibility()`** method of the [`Element`](https://developer.mozilla.org/en-US/docs/Web/API/Element) interface checks whether the element is visible. The method returns `false` in either of the following situations: - The element doesn't have an associated box, for example because the CSS [`display`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/display) property is set to [`none`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/display#none) or [`contents`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/display#contents). - The element is not being rendered because the element or an ancestor element sets the [`content-visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility) property to [`hidden`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility#hidden). The optional parameter enables additional checks to test for other interpretations of what "visible" means. For example, you can further check whether an element has an opacity of `0`, if the value of the element [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/visibility) property makes it invisible, or if the element [`content-visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility) property has a value of [`auto`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility#auto) and its rendering is currently being skipped. ## [Syntax](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#syntax) js ``` checkVisibility(options) ``` ### [Parameters](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#parameters) [`options` Optional](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#options) An object indicating additional checks to run. The possible options are: [`contentVisibilityAuto`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#contentvisibilityauto) `true` to check if the element [`content-visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility) property has (or inherits) the value [`auto`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility#auto), and it is currently skipping its rendering. `false` by default. [`opacityProperty`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#opacityproperty) `true` to check if the element [`opacity`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/opacity) property has (or inherits) a value of `0`. `false` by default. [`visibilityProperty`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#visibilityproperty) `true` to check if the element is invisible due to the value of its [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/visibility) property. `false` by default. [`checkOpacity`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#checkopacity) A historic alias for [`opacityProperty`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#opacityproperty). [`checkVisibilityCSS`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#checkvisibilitycss) A historic alias for [`visibilityProperty`](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#visibilityproperty). ### [Return value](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#return_value) `false` if any of the following conditions are met, otherwise `true`: - The element doesn't have an associated box. - The element [`content-visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility) property has (or inherits) a value of [`hidden`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/visibility#hidden). - `opacityProperty` (or `checkOpacity`) is `true` and the element [`opacity`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/opacity) property has (or inherits) a value of `0`. - `visibilityProperty` (or `checkVisibilityCSS`) is `true` and the element is invisible due to the value of its [`visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/visibility) property. - `contentVisibilityAuto` is `true`, the [`content-visibility`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility) property has (or inherits) a value of [`auto`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/content-visibility#auto), and element rendering is being skipped. ## [Examples](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#examples) ### [Test checkVisibility() with varied CSS](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#test_checkvisibility_with_varied_css) The following example allows you to test how the result of `checkVisibility()` might change with different values for `display`, `content-visibility`, `visibility`, and `opacity` CSS properties. #### HTML The HTML defines a `<select>` element for the CSS properties that affect the results of `checkVisibility()`. The first (default selected) values should result in `checkVisibility()` returning `true` when applied to an element, while the other values affect the visibility. html ``` <select id="css_display" name="css_display"> <option value="block" selected>display: block</option> <option value="none">display: none</option> <option value="contents">display: contents</option> </select> <select id="css_content_visibility" name="css_content_visibility"> <option value="visible" selected>content-visibility: visible</option> <option value="hidden">content-visibility: hidden</option> <option value="auto">content-visibility: auto</option> </select> <select id="css_opacity" name="css_opacity"> <option value="1" selected>opacity: 1</option> <option value="0">opacity: 0</option> </select> <select id="css_visibility" name="css_visibility"> <option value="visible" selected>visibility: visible</option> <option value="hidden">visibility: hidden</option> <option value="collapse">visibility: collapse</option> </select> ``` Next we have a `<pre>` that is used to output the result of the `checkVisibility()` check when no options are passed in the parameter, and for each separate option value. At the end we have the element that will be tested (to which we will apply the selected CSS property values). html ``` <pre id="output_result"></pre> <div id="test_element">The element to be checked for visibility.</div> ``` #### CSS The CSS just highlights the element to be tested. css ``` #test_element { border: solid; border-color: blue; } ``` #### JavaScript The code below gets each of the `<select>` elements. The `updateCSS()` method is called on start and whenever the select elements change in order to apply the selected CSS to the target element, js ``` const displayCssSelect = document.getElementById("css_display"); const contentVisibilityCssSelect = document.getElementById( "css_content_visibility", ); const displayCssOpacity = document.getElementById("css_opacity"); const displayCssVisibility = document.getElementById("css_visibility"); const outputResult = document.getElementById("output_result"); const elementToCheck = document.getElementById("test_element"); updateCSS(); const cssSelectors = document.querySelectorAll("select"); cssSelectors.forEach((select) => { select.addEventListener("change", (event) => { updateCSS(); }); }); function updateCSS() { // Apply selected CSS properties to target element elementToCheck.style.display = displayCssSelect.value; elementToCheck.style.contentVisibility = contentVisibilityCssSelect.value; elementToCheck.style.opacity = displayCssOpacity.value; elementToCheck.style.visibility = displayCssVisibility.value; // Call checkVisibility() on element using default and each of options const defaultVisibilityCheck = elementToCheck.checkVisibility(); const opacityVisibilityCheck = elementToCheck.checkVisibility({ opacityProperty: true, }); const cssVisibilityCheck = elementToCheck.checkVisibility({ visibilityProperty: true, }); const contentVisibilityAutoCheck = elementToCheck.checkVisibility({ contentVisibilityAuto: true, }); // Output the results of the tests outputResult.innerText = `Checks on element below (may be hidden): - Result of checkVisibility(): ${defaultVisibilityCheck} - Result of checkVisibility({opacityProperty: true}): ${opacityVisibilityCheck} - Result of checkVisibility({visibilityProperty: true}): ${cssVisibilityCheck} - Result of checkVisibility({contentVisibilityAuto: true}): ${contentVisibilityAutoCheck}`; } ``` #### Result The results are shown below. If you change the selection the results will be applied to the test element (blue outline) and the results of the `checkVisibility()` for each setting should be displayed. So for example, if you set the `opacity: 0` that test (only) should indicate `false`. However if you set `display: none` then all tests should return `false`. ## [Specifications](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#specifications) | Specification | |---| | [CSSOM View Module \# dom-element-checkvisibility](https://drafts.csswg.org/cssom-view-1/#dom-element-checkvisibility) | ## [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility#browser_compatibility)
Shard53 (laksa)
Root Hash7082249407640205653
Unparsed URLorg,mozilla!developer,/en-US/docs/Web/API/Element/checkVisibility s443