Q:

Best way to check an element's width?

Will checking the width attribute be sufficient to make sure my DOM element has a striclty positive width or should I also check for css rules (I am only looking for elements that have a fixed number of pixels as a CSS rule, no % width).
if (element.offsetWidth && element.offsetWidth > 0) // do stuff

OR
if ((element.offsetWidth && element.offsetWidth > 0)
     || (element.style && element.style.width
         && int(element.style.width.replace("px", ""), 10)>0 ) // do stuff

I would rather go for the first one but I want to make sure that setting the CSS rule will also set the width attribute.
---- EDIT ----
Actually offsetWidth seems to be better than width in any case. I changed width to offsetWidth.
Does it make the second option (checking for the CSS) worthless?

A:

element.offsetWidth should suffice - and no, checking the style element will not be necessary

