Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: Apply Box Sizing to Elements | Section
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
CSS Fundamentals for React Developers - 1768407374224

bookChallenge: 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-box value to the box-sizing property for the element with the content-box id.
  • Apply the border-box value to the box-sizing property for the element with the border-box id.
index.html

index.html

index.css

index.css

copy
  • 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.html

index.css

index.css

copy

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.

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 20

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

bookChallenge: Apply Box Sizing to Elements

Desliza para mostrar el menú

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-box value to the box-sizing property for the element with the content-box id.
  • Apply the border-box value to the box-sizing property for the element with the border-box id.
index.html

index.html

index.css

index.css

copy
  • 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.html

index.css

index.css

copy

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.

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 20
some-alt