Skip to main content

Bug Tracker

Side navigation

#14545 closed bug (wontfix)

Opened November 14, 2013 06:05PM UTC

Closed March 01, 2014 09:54PM UTC

In-body style element returns nonzero dimensions

Reported by: bggardner Owned by:
Priority: low Milestone: None
Component: css Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:

In HTML5, it is now valid to have style tags outside the head tag. jQuery returns nonzero dimensions (height(), width(), innerHeight(), etc.) for a style element inside of the HTML body tag. In the head tag, the correct (zero) dimensions are returned. JavaScript's clientHeight and clientWidth properties are zero, as expected. Only by setting the style tag's style attribute to "height: 0; width: 0" (or doing so in a stylesheet) will jQuery return zero for the dimension functions.

I have seen this in all jQuery versions available at jsfiddle, using Chrome and Firefox, both on Windows 7 and Ubuntu 13.10.


Attachments (0)
Change History (6)

Changed November 14, 2013 07:55PM UTC by timmywil comment:1

component: unfiledcss
priority: undecidedlow
status: newopen

This is valid. We're using swap here to ensure elements are not hidden when retrieving dimensions, but we can skip it for style elements.

Changed November 17, 2013 12:52PM UTC by bggardner comment:2

This also occurs with script elements.

Changed November 21, 2013 10:55AM UTC by grisendo comment:3

Changed November 21, 2013 11:09AM UTC by m_gol comment:4

What is an example use case that this bug is hurting?

Changed November 21, 2013 11:44AM UTC by grisendo comment:5

_comment0: Not sure how the reporter noticed it, but I can imagine an scenario like this: \ \ $('#some-id > *').each( ... if ($(this).height() > someValue) { ...1385034281831076

Not sure how the reporter noticed it, but I can imagine a scenario like this:

$('#some-id > *').each( ... if ($(this).height() > someValue) { ...

Changed March 01, 2014 09:54PM UTC by dmethvin comment:6

resolution: → wontfix
status: openclosed

See the discussion in, there's a docs ticket.