Wasn't I just so clever?« an older post
a newer one »Um... no.

5 + 3 ways to hide an element with CSS

Blog

I had a phone interview today with a company that I am incredibly hopeful to be contracting for shortly.

Comments

Hey, I got another one, how about changing around the axis so that it is 'flat' from the screen view via transform: rotateX(90deg) The element is still there of course but it's so flat and perpendicular with the screen that it doesn't show up in most modern browsers (try it).

Was the company Yelp by chance? I just got the same question with them today. I gave numbers 1,2,and 6 from your list. But when I asked afterwards what answers they were looking for it was 1 & 2, but their third was "set height:0;width:0;". I thought it was a bit weird they had one specific third answer, since there are clearly a bunch of ways to hide an element from the user.

The company wasn't Yelp, but that is another one!

I clearly need to update the title of this post. :)

Well that was pretty impressive to come to know about the different ways by which an element can be hidden with CSS. All the methods seemed effective to me and works perfectly too. I would love to try these methods out. Thanks for sharing.

Here is another one:

{width:0; height:0; overflow:hidden;}

Yes! Similar to the comment above, with the height and width values. Is the hidden overflow needed?

Simple, yet effective:

transform: scale(0);

Add new comment