Andrew's Digital Garden

Percentage based padding in CSS

Percentage based padding values on an element are based off the parent element's width. This is also true when setting the margin of the child element.

This is the magic behind the old aspect ratio padding hacks.

Note that the height of the child is still based off the height of the parent element.

[[css]]

Percentage based padding in CSS