1

I am furthering my understanding of CSS by studying Mozilla's code for Firefox.

In browser.css, the code reads:

.ac-tags-text[selected] > html|span.ac-tag {
  background-color: hsl(0, 0%, 100%);
  color: hsl(210, 80%, 40%);
}

html|span.ac-emphasize-text-title,
html|span.ac-emphasize-text-tag,
html|span.ac-emphasize-text-url {
  font-weight: 600;
}

Repeatedly, html|span is used instead of just span.

What other namespace is being protected by specifying the html namespace?

If specifying the namespace is needed, why is it not specified everywhere in the CSS code?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356

1 Answers1

4

What other namespace is being protected by specifying the html namespace?

If you're asking what the default namespace in browser.css is, it is the XUL namespace. You can find the namespace declarations where you would normally expect them — near the top of the stylesheet:

@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
@namespace html url("http://www.w3.org/1999/xhtml");
@namespace svg url("http://www.w3.org/2000/svg");

Since the default namespace is XUL, not HTML, all type selectors matching HTML elements must contain the html| namespace prefix, otherwise they'll attempt to match elements in the default namespace instead.

If specifying the namespace is needed, why is it not specified everywhere in the CSS code?

If you're asking why it's not specified for things like the [selected] attribute selector, it's because that attribute (along with a number of others) is part of the default namespace, not the HTML namespace.

If you're asking why it's not specified for things like the .ac-tags-text class selector, remember that compound selectors without an explicit type selector or universal selector are accompanied by an implicit *. Recall from one of your previous questions,

What is the difference between * and *|* in CSS?

that when a default namespace is specified, * matches elements of any type only in the default namespace. This prevents elements outside the default namespace (like HTML and SVG elements) from matching the selector even if they happen to have the same class name.

Community
  • 1
  • 1
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356