0
What is the use of padding?
4 Answers
+ 4
It provides breathing room between an element's content and the element's border (if any).
To provide some context, margins provide breathing room between the element's border (if any) and other elements, but margins tend to collapse / overlap by design.
To see this in action, poke around any website from a desktop or laptop and right click to inspect the elements. A box model should pop up to show you what the margin, border, and padding values are on each side of the element.
+ 1
create a div with fixed sizes for example width: 300px and height: 300px. Fill it with any color. Create another div inside first with 150px sides and fill with another color, write there some text. Play with margin and padding of second box and youâll get the idea :)
+ 1
okay. i understood, thank you guysđâ
+ 1
Youâre welcome!