If I have some HTML
<div id="container">
<div class="foo" style="width:75%;">Bar!</div>
</div>
and if I write this JavaScript (assuming jQuery for the benefit of the question)
alert( $("#container .foo")[0].style.width );
it should alert "75%". Will this output be consistent in every "modern" browsers? If not, what are the most popular non-standard browsers (even IE) that will fail to return the correct value?
** Edit **
PLEASE! There are only two statements with question marks... THOSE are the questions!
Now, let me add something that may help not mislead the answers...
- I know
element.style
is available across all browsers. - I know
element.style.width
is also available. - Using jQuery 1.3.2, calling
$("#container .foo").css('width')
does return"75%"
which is not true since at least version 1.6.4 (we're even beyond that major release too); the most recent jQuery version always output the width in pixels now.
So, considering the given HTML, will getting the element's style.width
always return the true, declared size (ie. in percentage) across all browsers, or is there any rogue, non-standard one that will return a computed width in pixels?