New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 6 users

Issue metadata

Status: WontFix
Closed: Apr 2015
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug

Sign in to add a comment

Element.innerText returns blank string when element has visibility: hidden set by CSS Stylesheet

Reported by, Sep 16 2011 Back to list

Issue description

Chrome Version       : 13.0.782.220
OS Version: 5.1 (Windows XP)
URLs (if applicable) :
Other browsers tested:
Add OK or FAIL after other browsers where you have tested this issue:
Safari 5:
Firefox 4.x:
IE 7/8/9:

What steps will reproduce the problem?
2. Access an element's innerText when it has visibility: hidden set by a CSS stylesheet
3. it will be "" rather than its actual content

What is the expected result?
Element.textContent works fine
This leads to several bugs in some frameworks also.

What happens instead?

Please provide any additional information below. Attach a screenshot if

UserAgentString: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1


Comment 1 by, Sep 16 2011

The second JS fiddle shows correct behavior when visibility: visible; shows using visibility: hidden along with textContent and how that functions as expected.

Comment 2 by Deleted ...@, Sep 30 2011

I've tried to print the innerText/textContent of a visibility:hidden div, here is the result. OK means can get the string, empty means only get empty string.

Safari 5: innerText: empty; textContent: OK.
Firefox 7: innerText: not support; textContent: OK.
IE 7/8: innerText: OK. textContent: not support.
IE 9: innerText: OK. textContent: OK.
opera 11: innerText: OK. textContent: OK.
Project Member

Comment 3 by, Mar 10 2013

Labels: -Area-Undefined

Comment 4 by, Apr 15 2015

Status: WontFix
This appears to be expected behaviour. Matches firefox.
Please use textContent instead.

Comment 5 by, Apr 15 2015

How could it match Firefox if Firefox doesn't support `innerText` in the first place? :)

IE and WebKit/Blink are the ones diverging on "visibility: hidden" behavior —

Considering that WebKit/Blink don't include "opacity: 0" elements, this is somehwat of a consistency issue. IE, on the other hand, only excludes "display: none" — which makes sense, since those are not part of the flow (unlike "visibility: hidden", "opacity: 0", "text-indent: -9999px", "color: transparent", and myriad of other ways one could come up with)

So I'd argue that WebKit/Blink behavior is the odd one. Whether that could be "fixed" is a different matter; there might be sites relying on this. And technically there's nothing to "fix" in the first place, since `innerText` has never been standardized.

Still, if this doesn't break anything, I think WebKit/Blink should follow IE lead in this particular aspect of problematic beast that innerText is :)

Sign in to add a comment