Siberian 13 Junior Poster

Has anyone used the Stylish extension for FireFox ? I can't get a style to effect an absolute URL and any and all pages within a absolute URL ?

Dani AI

Generated

— Stylish-style rules in Firefox rely on the @-moz-document (a.k.a. @document) matchers. To target an exact URL use url(), to target a path and every page under it use url-prefix(), and to match an entire domain use domain(). For more control use regexp() (the expression must match the whole URL). (developer.mozilla.org)

Simple, practical examples:

/* exact page (no trailing slash) OR the folder + everything under it */
@-moz-document url("https://example.com/abs/path"),
               url-prefix("https://example.com/abs/path/") {
  /* CSS rules here */
}

Notes: include both the url(...) form and a url-prefix(...) with a trailing slash when the site sometimes serves the folder URL with or without a slash; otherwise a page like https://example.com/abs/path might be missed.

If protocol or www variants must be handled, a regexp gives precise control (regexp must be escaped correctly and matches the whole URL):

@-moz-document regexp("https?://(www\\.)?example\\.com/abs/path(/.*)?$") {
  /* CSS rules here */
}

Regexp use and escaping are documented on MDN; test your expression carefully before relying on it. (developer.mozilla.org)

Troubleshooting tips: confirm the exact URL in the address bar (http vs https, presence/absence of www), check whether the extension’s “Applies to” UI is overriding or converting @-moz-document rules (some userstyle managers split/convert those into separate injections), and verify the style actually loaded with DevTools (make selectors specific or use !important when needed). See the Stylus/OpenStyles notes on how extensions handle @-moz-document sections. (github.com)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.