Live collection.document.links also includes <area href>.
Static snapshot.querySelectorAll("a[href]") is only <a> and does not auto-update.
Counts may match when there are no <area> elements.
Choose by need. All hyperlinks → links; filters/scopes → querySelectorAll.
Compatibility
Browser Support
Document.links is Baseline Widely available on MDN (since June 2018). It works across modern browsers as a standard Document collection.
✓ Baseline · Widely available
Document.links
Read-only live HTMLCollection of every a and area element with an href attribute.
99%Browser support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
linksExcellent
Bottom line: Safe for teaching and production. Prefer document.links for all hyperlinks; use querySelectorAll when you need CSS filters or a static snapshot.
Frequently Asked Questions
A read-only HTMLCollection of every <a> and <area> element in the document that has an href attribute — every hyperlink on the page (MDN).
No. MDN marks Document.links as Baseline Widely available (since June 2018). It is a standard Document collection property.
Anchor elements (<a href="...">) and image-map areas (<area href="...">). Elements without an href value are excluded.
document.links lists hyperlinks with href. document.anchors lists named anchors with a name attribute and is deprecated. Prefer links for hyperlink work.
Yes. Like other HTMLCollections, it updates when matching links are added or removed. Copy with Array.from if you mutate the DOM while looping.
Use document.links for every hyperlink quickly. Use querySelectorAll when you need filters (for example a.external), a scoped search, or a static NodeList snapshot.