tags:

views:

655

answers:

6

If so, does it effectively deprecate the visibility property?

(I realize that Internet Explorer does not yet support this CSS2 property.)
Comparisons of layout engines

See also: What is the difference between visibility:hidden and display:none

+2  A: 

I'm not entirely sure of this, but I think screen readers don't read things that are set to visibility hidden, but they may read things regardless of their opacity.

That's the only difference I can think of.

Phil
How would that effect the result then? Perhaps in terms of what is included in the DOM? My test cases show that Mozilla is not throwing away visibility:hidden elements.
Chris Noe
The elements would be in the DOM regardless of CSS style, I mean that blind users using screen reader software may have text in the opacity:0 element read to them, whereas they wouldn't if the same element had visibility:hidden. It's an accessibility concern really, as the result is different.
Phil
Got it. Thanks Phil.
Chris Noe
+3  A: 

Im not sure entirely, but this is how i do cross browser transparency:

opacity: 0.6;
-moz-opacity: 0.6;
filter: alpha(opacity=60);

objects with Visibility:hidden still have shape, they just arent visible. opacity zero elements can still be clicked and react to other events.

Andrew Bullock
What does it mean to have shape and be invisible?
Chris Noe
@chris, it means that they still take up the space on the page
Mitchel Sellers
opacity is used to decide how the element is drawn ontop of the background. With opactiy set to 0 the element naturally takes space but nothing is drawn because 0% of the element colour is mixed with 100% of the background resulting in nothing new appearing. hidden and similar friends mean the element is skipped when drawing takes place.
mP
A: 

What Phil says is true.

IE supports opacity though:

filter:alpha(opacity=0);
Diodeus
+4  A: 

Here is a compilation of verified information from the various answers.

Each of these CSS properties is in fact unique. In addition to rendering an element not visible, they have the following additional effect(s):

  1. Collapses the space that the element would normally occupy
  2. Responds to events (e.g., click, keypress)
  3. Participates in the taborder
                     collapse events taborder
opacity: 0              No     Yes     Yes
visibility: hidden      No     No      No
visibility: collapse    *      No      No
display: none          Yes     No      No

* Yes inside a table element, otherwise No.
Chris Noe
Help! Any advice on getting the table to format correctly?
Chris Noe
You need to tinker with it a bit, but use the <pre> tag.
Rob
Well now it's no longer a table, but a bit better I guess.
Chris Noe
I tried to follow the Markdown documentation here: http://daringfireball.net/projects/markdown/syntax
Chris Noe
Okay, so SO intentionally does not support <table>. So I made it ascii.
Chris Noe
A: 

The properties have different semantic meanings. While semantic CSS sounds like it may be silly, as other users have mentioned it has an impact on devices like screen readers -- where semantics impact the accessibility of a page.

Zack Mulgrew
A: 

No.

Elements with opacity create new stacking context.

Also, CSS spec doesn't define this, but elements with opacity:0 are clickable, and elements with visibility:hidden are not.

porneL