Skip to content

Comment on Shame.css

Comments

Why is overflow hidden a hack?

I think he was referring to those instances where you have something which as far as you can tell at the moment should be a certain height but inexplicably (at the moment, because you need it fixed now!) has this weird margin underneath it. With a quick look at the web inspector and your code you can't work out where it's coming from so in the interests of fixing a problem now, you might `overflow-y:hidden` it with the intent to come back later.

He didn't say that it was bad by itself, but when used to hide something instead of fixing it:

> "overflow:hidden;" instead of working out what’s actually broken our layout

overflow: hidden; is not a hack. It can do a lot of things which in his opinion are hacks (wtf).

Suggested reading: http://colinaarts.com/articles/the-magic-of-overflow-hidden/

It's not that overflow: hidden in itself is a hack, but it's application to counter collapsing due to floats. Already in the first paragraph, your link states that float containment is a side-effect. While I do use it for this exact reason, it leaves a bit of an aftertaste. And when it comes to css, isn't that the definition of a hack?

I think he was merely saying that it is a hack in the instance where a proper fix, without using overflow: hidden, COULD be found but in order to fix it NOW it was required to be used.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.