Learn CSS Box Model with Examples
29 November, 2022
2
2
0
Contributors
In this blog we will learn CSS Box Model and its Properties with Examples. Everything is represented by a box in CSS.
For example if we want to create a circle or we want browser to interpret our rectangular box as a circle then we can make a circle by changing the border-radius
to 100%.
•
•
•
•
Content
content
. Here whatever inside the green border
, is content
for outer box . Also the box inside it which has border
of 0
and the content
is red color for inner box.content
and the border
, we use padding
. It is helpful when we want to add extra space without changing the content size.Even after increasing class .bigBox
padding , it has no affect on the size of content.
In normal document flow( without using float , flex , grid etc.) if we have two siblings elements have some margin then only the largest of the two margins is used as space between these two elements.
box-sizing:border-box
our component will look like this.box-sizing
.css
100daysofcode
webdev
boxmodel
develevate