The :hidden selector matches elements that consume no layout space — hidden by display:none, zero size, hidden ancestors, or input type="hidden". jQuery extension since 1.0; opposite of :visible.
01
Syntax
:hidden
02
display
none
03
Official
Count & show
04
:visible
Opposite
05
Not hidden
opacity, visibility
06
.filter()
Performance
Fundamentals
Introduction
Toggle panels, reveal accordions, audit form fields, and debug UI state — you often need to find elements that are not shown on the page. jQuery’s :hidden pseudo-class selects every element that consumes no space in the document layout.
jQuery has supported :hidden since version 1.0. Official documentation lists several reasons an element is hidden: CSS display:none, type="hidden" inputs, explicit zero width/height, or a hidden ancestor. Because checking visibility can force layout recalculation, prefer scoping with CSS first, then .filter(":hidden"), or track state with a class when performance matters.
Concept
Understanding the :hidden Selector
An element is :hidden when it (or an ancestor) consumes no layout space:
display: none → matches :hidden.
input type="hidden" → matches :hidden.
width: 0; height: 0 (explicit) → matches :hidden.
Inside a hidden parent → child also matches :hidden.
visibility: hidden or opacity: 0 → still visible to jQuery (uses space).
💡
Beginner Tip
:hidden is about layout boxes, not whether you can see pixels. A transparent or invisible-but-sized element is :visible, not :hidden.
Layout visibility vs pixel visibility vs manual state tracking.
:hidden
$("div:hidden")
No layout box
:visible
$("div:visible")
Opposite set
[hidden]
$("[hidden]")
HTML attribute
.is-hidden
$(".is-hidden")
Class (fast)
Hands-On
Examples Gallery
Example 1 follows the official jQuery hidden demo. Examples 2–5 cover visibility vs display, scoped .filter(":hidden"), hidden inputs, and revealing panels with .show().
Span shows total hidden elements (excluding script)
Hidden purple divs fade in over 3 seconds
Second span reports hidden input count
How It Works
jQuery walks the DOM and tests layout boxes. Elements with display:none or hidden ancestors match; the official demo excludes script tags from the total count.
Example 2 — display:none vs visibility:hidden
Only display:none matches :hidden — invisible but sized elements stay :visible.
Click "Show all" → hidden accordion panels slide down
Visible panel stays open
How It Works
Combine scoped div:hidden with effects — only panels with no layout box are targeted.
Applications
🚀 Common Use Cases
Debug UI — count hidden nodes with $("body").find(":hidden").not("script").
Reveal panels — $("div:hidden").show() as in the official demo.
Forms — iterate input:hidden tokens and IDs.
Accordions — open closed sections with div:hidden + .slideDown().
Validation — ensure required visible fields are not inside hidden parents.
Performance — scope then .filter(":hidden") instead of global scans.
🧠 How jQuery Evaluates :hidden
1
Build candidate set
Evaluate prefix — all elements, div:hidden, or scoped descendants.
Query
2
Check layout boxes
Test whether the element or any ancestor consumes space — may trigger layout work.
Layout
3
Apply jQuery rules
Ignore visibility/opacity; treat type=hidden and display:none as hidden; jQuery 3+ skips elements with no boxes.
Rules
4
✓
Return collection
Complement of :visible — chain .show(), .each(), or read .length.
Important
📝 Notes
Available since jQuery 1.0 — jQuery extension, not native CSS.
Opposite of :visible — partitions the DOM into two sets.
visibility:hidden and opacity:0 are not :hidden.
Hidden ancestors hide descendants — children also match :hidden.
Official demo excludes script from body hidden counts in some browsers.
Heavy use can hurt performance — prefer classes or scoped .filter().
jQuery 3+: elements without layout boxes (e.g. empty inline, br) are :hidden.
Compatibility
Browser Support
The :hidden pseudo-class is a jQuery extension and works in jQuery 1.0+. Visibility tests run through jQuery’s engine consistently across browsers, but may force layout recalculation. Use scoped .filter(":hidden") or state classes when performance is critical.
✓ jQuery 1.0+ · extension
jQuery :hidden Selector
Layout-based hiding — not the same as CSS visibility or opacity.
100%jQuery only
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
:hiddenExtension
Bottom line: Pair with :visible — scope first, then filter on large pages.
Wrap Up
Conclusion
The :hidden selector matches elements that consume no layout space — through display:none, zero size, hidden ancestors, or input type="hidden". The official demo counts hidden nodes and animates hidden divs visible.
Remember it is the opposite of :visible, ignore visibility/opacity for matching, and prefer scoped .filter(":hidden") when performance matters.
Run bare $(":hidden") on huge DOM trees repeatedly
Use :hidden in native CSS — jQuery-only extension
Confuse with HTML [hidden] attribute alone
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about :hidden
Layout boxes, not pixel visibility.
5
Core concepts
👁01
:hidden
No layout box
API
:visible02
Opposite
Complement
Rule
none03
display
Hidden
CSS
demo04
Official
Count & show
Demo
.filter05
Scope
Performance
Tip
❓ Frequently Asked Questions
:hidden selects elements that are hidden — they consume no space in the document layout. Common cases include display:none, input type="hidden", zero width/height, or a hidden ancestor. Available since jQuery 1.0.
No. Elements with visibility:hidden or opacity:0 still take up space in the layout, so jQuery treats them as visible. Only elements that consume no layout space match :hidden.
Yes. Every element selected by :hidden is not selected by :visible, and vice versa. They are complementary filters in jQuery.
No. It is a jQuery extension and does not work in native querySelectorAll(). Official docs recommend selecting with a CSS scope first, then .filter(":hidden") for better performance.
In some browsers, $("body").find(":hidden") also matches head, title, script, and other non-visible document nodes. The official demo excludes script tags before counting user-facing hidden elements.
Starting with jQuery 3, elements without layout boxes — such as br and empty inline elements — are considered :hidden. This slightly refines how :hidden and :visible divide the DOM.
Did you know?
During show/hide animations, jQuery treats elements as :visible at the start of a show animation and as :hidden until a hide animation completes. That timing affects which elements match during transitions.