:password selects every element of type password — usually <input type="password">. Official docs: equivalent to $("[type=password]"). Available since jQuery 1.0.
!
Not CSS / jQuery extension
Prefer input[type="password"] for native querySelectorAll speed. Always write input:password — bare :password implies *:password.
Remember
$("input:password") → recommended
$("[type=password]") → equivalent (official)
$("input[type='password']") → best for modern browsers
$(":password") → means *:password (avoid)
<input type="password"> → matches
<input type="text"> → no match
login form: pwd
all page: pwd, pin
filled length: 6
How It Works
Scoped query.#login input:password stays inside one form.
Page-wide query. Also picks up pin in another form.
Length check. Demo reports .val().length, not the secret itself.
Production tip. Always scope validation to the submitted form.
Edge Cases & Pitfalls
Check these before relying on :password in real projects.
prefix
Avoid bare :password
Official docs: bare form implies *:password. Always write input:password.
css
jQuery extension only
Not in querySelectorAll. Prefer input[type="password"] for native speed.
scope
Multiple forms
Page-wide queries can style or validate password fields you did not intend — scope to a form id.
security
Do not log secrets
Avoid console.log($("input:password").val()) in real apps. Check emptiness or length instead.
Compatibility
Browser Support
:password is a jQuery extension (not CSS), available since 1.0. Equivalent attribute matching with input[type="password"] works in native querySelectorAll.
✓ jQuery 1.0+ · Extension
jQuery :password
Works in all browsers with jQuery. Prefer input[type="password"] for native CSS performance.
100%jQuery environments
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
:passwordjQuery + attr CSS
Bottom line: Use input:password in jQuery tutorials; prefer input[type="password"] when performance matters.
Analysis
Performance Notes
Approach
Cost
Best for
$("input[type='password']")
Native QSA
Official recommended pattern
$("input:password")
Sizzle path (no QSA)
Learning / small pages
$("#form input:password")
Smaller scoped set
Multi-form pages
Official docs: because :password is not CSS, use [type="password"] in modern browsers for the native performance boost.
Remember
Key Takeaways
Role: select type="password" inputs.
Prefix: write input:password, not bare :password.
Equivalent: same set as [type=password].
Perf: prefer input[type="password"] in modern browsers.
One line::password means “password-type inputs” — prefix with input, prefer the attribute form for speed.
Frequently Asked Questions
:password selects every element of type password — typically <input type="password">. $("input:password") finds all password fields in scope. Available since jQuery 1.0.
Yes. Official docs: $( ":password" ) is equivalent to $( "[type=password]" ). For native querySelectorAll speed, prefer input[type="password"].
Prefer $("input:password"). Bare $(':password') implies the universal selector ($('*:password')). Official docs recommend preceding it with a tag name.
No. It is a jQuery extension. Native querySelectorAll cannot run :password. Use input[type="password"] for standard CSS matching.
:password matches masked password inputs. :text matches plain text inputs. They never overlap.
It styles $("input:password") and reports how many were found in a sample form that also includes text, textarea, checkbox, radio, select, and button controls.