โ† All CSS Flashcard Decks

CSS Box Model & Spacing Flashcards

7 cards from real CSS practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 CSS Box Model & Spacing flashcards as text
  1. What are the four layers that make up the CSS box model, from innermost to outermost?

    Answer: Content, padding, border, margin

    The CSS box model consists of content at the center, surrounded by padding, then border, then margin as the outermost layer.

  2. Which value of the `box-sizing` property makes an element's total rendered width include padding and border?

    Answer: border-box

    `box-sizing: border-box` causes padding and border to be included within the declared width/height, preventing unexpected size increases.

  3. What is the default value of the `box-sizing` property in CSS?

    Answer: content-box

    By default, `box-sizing: content-box` is applied, meaning padding and border are added on top of the declared width/height.

  4. What does `margin: auto` typically achieve when applied to a block element with a defined width?

    Answer: Centers the element horizontally within its container

    Setting `margin: auto` on left and right distributes the remaining space equally on both sides, horizontally centering the block element.

  5. When four values are provided to the `margin` shorthand (e.g., `margin: 10px 20px 30px 40px`), in what order are they applied?

    Answer: Top, right, bottom, left

    CSS shorthand with four values follows the clockwise order: top, right, bottom, left (remember TRBL or 'trouble').

  6. What does `padding: 10px 20px` set for an element?

    Answer: Top/bottom = 10px, left/right = 20px

    With two values, the first applies to top and bottom, and the second applies to left and right.

  7. Which CSS property controls the space between an element's content area and its border?

    Answer: padding

    Padding creates space between the content and the border, pushing the border away from the content.