Challenge: Apply Box Sizing to Elements
Task
Let's explore the practical differences between the content-box and border-box values for the box-sizing property. Your task is as follows:
- Apply the
content-boxvalue to thebox-sizingproperty for the element with thecontent-boxid. - Apply the
border-boxvalue to thebox-sizingproperty for the element with theborder-boxid.
index.html
index.css
box-sizing: content-box: Width and height exclude padding and border.box-sizing: border-box: Width and height include padding and border.
index.html
index.css
Explanation
- The first box uses
content-box(the default). Width and height apply only to the content, so padding and border increase its final size beyond 200×200px; - The second box uses
border-box. Width and height include content, padding, and border, so the overall size stays exactly 200×200px.
This makes the first box visibly larger, while the second remains consistent regardless of added padding or border.
Takk for tilbakemeldingene dine!
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Fantastisk!
Completion rate forbedret til 2.56
Challenge: Apply Box Sizing to Elements
Sveip for å vise menyen
Task
Let's explore the practical differences between the content-box and border-box values for the box-sizing property. Your task is as follows:
- Apply the
content-boxvalue to thebox-sizingproperty for the element with thecontent-boxid. - Apply the
border-boxvalue to thebox-sizingproperty for the element with theborder-boxid.
index.html
index.css
box-sizing: content-box: Width and height exclude padding and border.box-sizing: border-box: Width and height include padding and border.
index.html
index.css
Explanation
- The first box uses
content-box(the default). Width and height apply only to the content, so padding and border increase its final size beyond 200×200px; - The second box uses
border-box. Width and height include content, padding, and border, so the overall size stays exactly 200×200px.
This makes the first box visibly larger, while the second remains consistent regardless of added padding or border.
Takk for tilbakemeldingene dine!