Skip to content

Conversation

@codersjj
Copy link
Contributor

Description

Add note clarifying that the universal selector does not match pseudo-elements.

This PR adds a clarification note to the Universal selector (*) documentation to explain that it matches elements only, not pseudo-elements. This helps avoid the common misunderstanding that the universal selector can directly select pseudo-elements.

Motivation

The current MDN page states that:

“The CSS universal selector (*) matches elements of any type.”

However:

  • It does not explicitly distinguish “elements” from “pseudo-elements”.
  • Developers often confuse *::before with “universal selector matching pseudo-elements”.
  • In reality, *::before means “match all elements, then apply the ::before pseudo-element”.

This PR adds a concise NOTE block clarifying this behavior.

Additional details

CSS Selectors Level 4

  1. Universal selector definition:
  1. Pseudo-elements:

These specifications collectively establish that pseudo-elements are abstract representations bound to originating elements rather than actual elements in the document tree, therefore the universal selector—which exclusively targets elements—cannot match pseudo-elements directly.

Related issues and pull requests

@codersjj codersjj requested a review from a team as a code owner November 16, 2025 09:06
@codersjj codersjj requested review from chrisdavidmills and removed request for a team November 16, 2025 09:06
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed labels Nov 16, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 16, 2025

Preview URLs

Flaws (2)

URL: /en-US/docs/Web/CSS/Reference/Selectors/Universal_selectors
Title: Universal selectors
Flaw count: 2

  • macros:
    • Macro produces link /en-US/docs/Web/CSS/@namespace which is a redirect
    • Macro produces link /en-US/docs/Web/CSS/::before which is a redirect

(comment last updated: 2025-11-17 17:33:16)

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

@codersjj You are correct, and I think this is a good addition to the page. However, I feel that your second and last sentences are a bit repetitive. I've provided some suggestions for fixing this problem and making the provided example a bit clearer/more instructive.

Let me know what you think.

codersjj and others added 2 commits November 17, 2025 22:56
…dex.md

Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>
…dex.md

Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>
@codersjj
Copy link
Contributor Author

@codersjj You are correct, and I think this is a good addition to the page. However, I feel that your second and last sentences are a bit repetitive. I've provided some suggestions for fixing this problem and making the provided example a bit clearer/more instructive.

Let me know what you think.

@chrisdavidmills LGTM! 👍

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

Looking good, thanks @codersjj! Let's get this merged.

@chrisdavidmills chrisdavidmills merged commit ca0d81a into mdn:main Nov 17, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:CSS Cascading Style Sheets docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants