News for hackers. Stuff that matters.
Re:CSS sucks because we don't bother learning it (2022) by nicoburns on Monday January 05, 2026 @12:31PM (#46501857)
> Why do you think the padding as a percentage is relative to the width of the parent

The serious answer is:

1. Many early web engines used `display: content-box`. So the padding was actually considered to be outside of the box itself.

2. Early web engines were strict about height-can-depend-on-width, but width-cannot-depend-on-height to avoid circular dependencies.

Re:CSS sucks because we don't bother learning it (2022) by Izkata on Monday January 05, 2026 @02:12PM (#46503266)
> 1. Many early web engines used `display: content-box`. So the padding was actually considered to be outside of the box itself.

IIRC this was actually the spec, and IE decided to ignore it and do something saner, while the box-sizing attribute to pick what you wanted came later. Designing for content-box and IE displaying using border-box (or whatever it did) was one of the reasons it got the nickname "internet exploder" - everything ended up positioned or sized wrong. Until box-sizing came along, it was common to use various hacks / bugs in the browsers' CSS parsers to make certain rules only apply to certain browsers to fix this.

Re:CSS sucks because we don't bother learning it (2022) by nicoburns on Monday January 05, 2026 @02:28PM (#46503509)
> IIRC this was actually the spec, and IE decided to ignore it and do something saner

That's actually a little unfair on IE. This behaviour predates there even being a spec. IE and Netscape did it differently, and as a general rule Netscape's behaviour tended to be what ended up in the spec. This was mostly a good thing, but not so much in this case.

Re:CSS sucks because we don't bother learning it (2022) by throwawayffffas on Monday January 05, 2026 @01:38PM (#46502785)
While that's true. They could have gone another way without breaking the dependency rules.

Padding top and bottom could be relative to parent height and padding left and right could be relative to parent width. They would not be the same. But it would still make sense. It would arguably be more logical than the selected behavior.

But the specific example does not even invalidate my point there is a whole website about css quirky behaviors and how to use them to your advantage, https://css-tricks.com/.