2

Just want to be sure.

Given the following:

if( ! ( jQuery(slider).css('max-height') == 'none') )
  return 200;
else
  ...carry on...

Can I always assume that if a CSS property is not set in the stylesheet that the .css() method will always return 'none'? It doesn't say so in the jQuery docs but it -seems- like it does. If there's a more standardised way to do this, please let me know. Thanks.

2
  • 1
    each CSS element has a default applied by the browser's stylesheet Commented Oct 29, 2013 at 20:48
  • 1
    So that implies that the default for 'max-height' is 'none' but it might be 'auto' or '0' for another property? Is there a standard way to determine if a property is explicitly set? (ie. not using the default)? Commented Oct 29, 2013 at 20:51

1 Answer 1

1

No, the default for max-height is none. Hence, your condition is valid.

but, for example the default for z-index is auto. So, you have to handle each CSS property by its default value.

Sign up to request clarification or add additional context in comments.

4 Comments

Probably stupid question, but... Is there a W3C document which gives these values? If so, where is it?
this jsFiddle might help, you can add on things as you need it => jsfiddle.net/8UbXy. and @jchwebdev, there are standards, and there are browsers, but to say all browsers are based on standards would be a l-IE.
I'm wondering how safe my example is for long-term use. IOW: Is 'none' likely to change in the near future? OR... is there a -better- (standard) method I can use to determine whether -any- property is explicitly set? That's really what I'm looking for. THANKS!
@jchwebdev - i think checking for the css attribute should be enough & I think trying to see if a property is explicitly set would be an overkill if that's even possible. I'm not sure if there is such a way though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.