Skip to content

docs: clarify difference between Document.querySelector() and Element.querySelector()#43476

Closed
dsk-dev-ai wants to merge 13 commits intomdn:mainfrom
dsk-dev-ai:fix-queryselector-difference
Closed

docs: clarify difference between Document.querySelector() and Element.querySelector()#43476
dsk-dev-ai wants to merge 13 commits intomdn:mainfrom
dsk-dev-ai:fix-queryselector-difference

Conversation

@dsk-dev-ai
Copy link
Contributor

Description

Adds a clarification explaining the difference between Document.querySelector() and Element.querySelector().

Motivation

This distinction is a common source of confusion for developers. The documentation previously did not clearly explain the scope difference between these two methods. This update helps readers better understand how each method works in practice.

Additional details

No functional changes. This is a documentation improvement with a simple example to illustrate the difference.

Related issues and pull requests

Fixes #43367
Relates to #43367

@dsk-dev-ai dsk-dev-ai requested a review from a team as a code owner March 17, 2026 13:48
@dsk-dev-ai dsk-dev-ai requested review from pepelsbey and removed request for a team March 17, 2026 13:48
@github-actions github-actions bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Mar 17, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

Preview URLs (1 page)

(comment last updated: 2026-03-21 05:23:41)

Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for trying to help! Unfortunately, it doesn't address the mentioned issue: you're even changing a different page. Please read carefully what the issue is all about.

@dsk-dev-ai
Copy link
Contributor Author

Thank you for trying to help! Unfortunately, it doesn't address the mentioned issue: you're even changing a different page. Please read carefully what the issue is all about.

Thank you for clarification, I try to figure out things and update that...

Copy link
Contributor Author

@dsk-dev-ai dsk-dev-ai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback!

I have updated the PR to add a concise clarification in the main description section instead of introducing a new section, keeping the change aligned with the issue scope.

Please let me know if anything else should be adjusted.

Clarify the behavior of Document.querySelector() and Element.querySelector() in the note section.
Copy link
Contributor Author

@dsk-dev-ai dsk-dev-ai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I resolved the issue of failing

@dsk-dev-ai dsk-dev-ai requested a review from pepelsbey March 20, 2026 03:36
@dsk-dev-ai
Copy link
Contributor Author

plz review it

@pepelsbey
Copy link
Member

I just noticed it's a duplicate PR. It's already being fixed: #43387

@pepelsbey pepelsbey closed this Mar 22, 2026
@dsk-dev-ai
Copy link
Contributor Author

I just noticed it's a duplicate PR. It's already being fixed: #43387

Thank you for explaination

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document.querySelector() vs. Element.querySelector()

3 participants