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

44

u/Lugicarus Mar 01 '17 edited Mar 01 '17

Hey I'm Lugicarus and I'm a front end developer or web designer - I dont know all titles are made up and I can't remember if display: hidden or display: none does this shit I want it to. Every single time.

Pro tip! It's always display: none.

Edit: y'all are some salty devs. It's satire after all! Sheesh

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.

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?