A repository of over 1000 quality jQuery plugins

jQuery jQuery.cssNumber

Learn all about the jQuery function jQuery.cssNumber.

You can think about jQuery.cssNumber as a list of all CSS properties you might use without a unit. It’s used by .css() to determine if it needs to add px to unitless values.

The keys of the jQuery.cssNumber object are camel-cased and the values are all set to true. If you want to prevent the .css() method from automatically adding the px unit for a specific CSS property, you can add an extra property to the jQuery.cssNumber object.

1
jQuery.cssNumber.someCSSProp = true;

By default the object contains the following properties:

  • zIndex
  • fontWeight
  • opacity
  • zoom
  • lineHeight
  • widows (added in jQuery 1.6)
  • orphans (added in jQuery 1.6)
  • fillOpacity (added in jQuery 1.6.2)
  • columnCount (added in jQuery 1.9)
  • order (added in jQuery 1.10.2)
  • flexGrow (added in jQuery 1.11.1)
  • flexShrink (added in jQuery 1.11.1)