itsjavi
itsjavi

Reputation: 2662

Is it possible to detect support of CSS3 functions like attr() or url() using Modernizr?

I've been searching for a while for a Modernizr test for CSS functions like attr(), but I couldn't find anything. Is there a way to test these features?

Upvotes: 3

Views: 241

Answers (1)

BoltClock
BoltClock

Reputation: 723729

CSS functions vary a great deal in their use, and count as values rather than properties or selectors, so there isn't a generic Modernizr test for them. However, it does provide feature detection for some specific functions:

  • RGBA and HSLA color values: Modernizr.rgba and Modernizr.hsla

  • Gradients: Modernizr.cssgradients

  • Transforms: Modernizr.csstransforms for 2D transforms and Modernizr.csstransforms3d for 3D transforms

Modernizr does not provide feature detection for url() because that has been around forever and every browser supports it fully.

It also does not provide feature detection for attr(), but for what it's worth, every browser that does implement attr() (IE8+ and other browsers) only implements it as defined in CSS2.1. As of 2013, no implementation exists for the version defined in Values and Units level 3.

Note that CSS2.1 attr() is only usable with the content property on the :before and :after pseudo-elements, which Modernizr does offer feature detection for in the form of Modernizr.generatedcontent.

Upvotes: 1

Related Questions