Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does @-moz-document url-prefix() do?

In Simon Collison's new old Responsive Web Design, in the CSS, there are several declarations like this:

@-moz-document url-prefix() {   .fl { float:left; margin:12px 4px 0 0; padding:0; font-size:65px;  line-height:62%;  color:#ba1820; }   .fs { float:left; margin:12px 4px 10px 0; padding:0; font-size:65px; line-height:62%; color:#ba1820; } } 

What does this actually do? I've googled for @-moz-document url-prefix() and have found references for its use within userchrome but not standard site stylesheets.

It usually has a URL passed in as an argument which then restricts the content of the declaration to that URL. However, on Colly's site, there is no argument being passed in. This would indicate that the declaration is operating on the current URL, or any URL, no? So is what we're seeing here a way of targeting Mozilla-only browsers with certain rules?

like image 406
Charles Roper Avatar asked Jun 26 '10 07:06

Charles Roper


Video Answer


2 Answers

Any CSS at-rule that starts with @-moz- is a Gecko-engine-specific rule, not a standard rule. That is, it is a Mozilla-specific extension.

The url-prefix rule applies the contained style rules to any page whose URL starts with it. When used with no URL argument like @-moz-document url-prefix() it applies to ALL pages. That's effectively a CSS hack used to only target Gecko (Mozilla Firefox). All other browsers will ignore the styles.

See here for a list of other Mozilla-specific extensions.

like image 58
Oded Avatar answered Sep 20 '22 22:09

Oded


From https://developer.mozilla.org/en/CSS/@-moz-document

       @-moz-document url(http://www.w3.org/),                    url-prefix(http://www.w3.org/Style/),                    domain(mozilla.org)     {       /* CSS rules here apply to:          + The page "http://www.w3.org/".          + Any page whose URL begins with "http://www.w3.org/Style/"          + Any page whose URL's host is "mozilla.org" or ends with            ".mozilla.org"        */        /* make the above-mentioned pages really ugly */       body { color: purple; background: yellow; } } 
like image 26
Bella Avatar answered Sep 18 '22 22:09

Bella