Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8120051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:59:56+00:00 2026-06-06T04:59:56+00:00

When using namespaces in CSS, you can select, for example, any div element in

  • 0

When using namespaces in CSS, you can select, for example, any div element in “any or no namespace” by using a namespaced type selector:

*|div

Is it valid CSS to namespace a pseudo-class? For example:

*|:first-child

It seems to work in WebKit based browsers, and it seems to not work in IE9 (below IE9 does not support namespaces at all) and Firefox. I don’t care what browsers it does/doesn’t work in, I just need to know whether it is a valid construct.

Here’s a fiddle.

From what I can make out in the CSS grammar, it is not valid. But I may be misreading the grammar.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:59:58+00:00Added an answer on June 6, 2026 at 4:59 am

    Namespaces, as part of the document language, do not apply directly to pseudo-classes or pseudo-elements, as they’re defined in CSS and not the document language (e.g. XML). Element types and attributes, however, are defined in the document language as opposed to CSS, which is why they can be namespaced. Consequently, in a sequence of simple selectors, the universal selector specifically means “any type”.

    The universal selector is only implied for other simple selectors and pseudo-elements when used without a namespace (this is why selectors like .foo, #target, [type="text"], :first-child and ::before are valid, and generally used with languages like HTML where CSS is most commonly used for styling). From the spec:

    If a universal selector represented by * (i.e. without a namespace prefix) is not the only component of a sequence of simple selectors selectors or is immediately followed by a pseudo-element, then the * may be omitted and the universal selector’s presence implied.

    Therefore, in your example, the selector is invalid because there’s neither a universal selector or a type selector between the | and the ::

    /* These are all invalid */
    *|:first-child
    ns|::first-letter
    |::before
    

    If you specify a namespace, you must specify the universal selector if you don’t select a specific type instead:

    *|*:first-child
    *|*::before
    

    The same goes when selecting elements in an ns namespace:

    ns|*:first-child
    ns|*::before
    

    Or when selecting elements that are not in a namespace:

    |*:first-child
    |*::before
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the System.IO.Compression namespaces classes GZIPStream and DeflateStream I successfully can compress and decompress
Using import aliasing in one file/class, we can reference class library namespaces by assigning
I understand the pros of using namespaces within the actual application layers but when
What naming conventions are you using for namespaces and sponsor classes? (i.e. the classes
It seems to me that using unanchored namespaces is just asking for trouble later
I am using the DOM extension to parse an xml file containing xml namespaces
using namespace std; class A { public: A() {} ~A() {} map<int, string*>& getMap()
In my C++ code I don't use the declarations using namespace std; or using
I've recently been working with code that looks like this: using namespace std; class
for using cout , I need to specify both: #include<iostream> and using namespace std;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.