Search code examples
cssfirefoxbrowser-detection

Is it possible to detect Firefox users in pure CSS?


Is it possible to detect Firefox Browser only with CSS like IE?

for example, IE browser can be detected like:

<!--[if IE 7]>
   /* IMPORTING CSS FOR IE */
<![endif]-->

Can be Firefox browser detected like this code?


Solution

  • The Mozilla Developer Network states this is explicitly supported just for browser detection:

    @-moz-document url-prefix() {
     
        #my-id { font-size: 100%; }
     
    }
    

    See the Firefox note in @document § browser compatibility, which states FF 61+ "only supports an empty url-prefix() value, which is supported due to its use in Firefox browser detection. Still supported in user stylesheets."

    Place this in your CSS file or between your <style type='text/css'> tags in your HTML.