r/webdev • • Mar 01 '17

Programmers are confessing their coding sins to protest a broken job interview process

https://theoutline.com/post/1166/programmers-are-confessing-their-coding-sins-to-protest-a-broken-job-interview-process
1.4k Upvotes

341 comments sorted by

View all comments

Show parent comments

56

u/iamallamaa Mar 01 '17

display: none vs visibility: hidden. Display will remove the element from the flow of the document, making the element disappear visually as if it wasn't there. Visibility is like setting the opacity down to 0%. It still occupies a space visually and stuff flows around it.

46

u/amoliski Mar 01 '17 edited Mar 02 '17

Says a person who almost certainly just googled that to make sure they were correct before commenting

32

u/madcapmonster Mar 01 '17

I actually know that one from years of banging my head against a wall. It finally stuck. (the concept, not my head)

2

u/midri Mar 02 '17

It's actually really easy to remember. Dispaly: none you use. Visibility: is never used.

1

u/daaaaaaBULLS Mar 02 '17

I was asked the difference in an interview this week and said the correct thing while in my head hoping what I was saying was the correct thing.

4

u/RetroEvolute Mar 02 '17

Although, with visibility: hidden, element events are also disabled, whereas opacity still retains its events even though you cannot see it. So:

  • If you're hiding something and don't want it to take up space or be clickable, use display: none.

  • If you're hiding something and want it to take up space, still be clickable, and want to use a transition to smoothly show or hide it, use opacity.

  • If you're hiding something, still want it to take up space, but don't want it clickable, then use visibility: hidden.

You also used to be able to combine opacity and visibility with some clever transitions and delays to make something fade out and then be non-interactive (which is awesome), but browsers seem to have issue with this in a lot of cases.

Oh, and there's also visibility: collapse which is for tables, but who cares about that one?

1

u/[deleted] Mar 02 '17

visibility:visible is annoying to spell.