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 8038627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:17:41+00:00 2026-06-05T03:17:41+00:00

So I need to detect if a user’s browser supports CSS gradients, that’s it.

  • 0

So I need to detect if a user’s browser supports CSS gradients, that’s it. I would use Modernizr, but even with only including gradient detection, it would be wasteful compared to just doing it myself.

As I understand it, this would be how to go about it;

  1. Creating an element that isn’t added to the DOM
  2. Setting background-image to linear-gradient with all the vendor prefixes
  3. Reading background-image and checking for gradient, to see if it’s still there

I couldn’t figure out Modernizr’s source though, what’s the core of what they’re doing in this? So I can do it myself. http://modernizr.com/download/#-cssgradients-prefixes

  • 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-05T03:17:42+00:00Added an answer on June 5, 2026 at 3:17 am

    Their test is really basic and you can just extract it:

        function supports_gradients() {
        /**
         * For CSS Gradients syntax, please see:
         * webkit.org/blog/175/introducing-css-gradients/
         * developer.mozilla.org/en/CSS/-moz-linear-gradient
         * developer.mozilla.org/en/CSS/-moz-radial-gradient
         * dev.w3.org/csswg/css3-images/#gradients-
         */
    
        var str1 = 'background-image:',
            str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));',
            str3 = 'linear-gradient(left top,#9f9, white);';
    
        setCss(
             // legacy webkit syntax (FIXME: remove when syntax not in use anymore)
              (str1 + '-webkit- '.split(' ').join(str2 + str1)
             // standard syntax             // trailing 'background-image:'
              + prefixes.join(str3 + str1)).slice(0, -str1.length)
        );
    
        return contains(mStyle.backgroundImage, 'gradient');
    };
    

    For this to work you’d also have to extract contains() and setCss() unless you’ve got your own versions of these methods (say, from jQuery).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to detect if the user is using an iPhone 4, but I
I need to detect the user finger-press, there's already the tap event, but tap
Hallo. I need know user name of user which run browser. If I use
I need to be able to detect whether the current language my user is
I need to detect whether the user has pressed the dot key in the
I am developing an Android app and I am need to detect user context
I need to detect if a user is scrolled to the bottom of a
I need to detect where the user has just clicked from - as my
I need some javascript or php code to detect if user has linked directly
I need to automatically detect if a user requires a proxy to access the

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.