Box Model Flashcards

(20 cards)

1
Q

What are the four parts of the CSS box model?

A

Content, padding, border, and margin — from innermost to outermost.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does box-sizing: content-box do?

A

It’s the default. Width and height apply only to the content area. Padding and border are added on top, making the rendered box larger than the specified dimensions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does box-sizing: border-box do?

A

Width and height include content, padding, and border. The content area shrinks to accommodate padding and border within the specified dimensions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why is border-box often preferred for layout?

A

It makes sizing more predictable — the total rendered size matches the width/height you set, so elements with padding and borders still fit their intended space.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the content area?

A

The area where text, images, or other content is displayed. Its size is controlled by the width and height properties (in content-box mode).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the padding area?

A

The space between the content and the border. It extends the content area and is controlled by the padding properties.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the border area?

A

The area wrapping content and padding. Its thickness is set by border-width and related properties.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the margin area?

A

The outermost layer — empty space outside the border that separates the element from its neighbors. Controlled by margin properties.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Is the margin included in the element’s total size?

A

No. The margin affects space on the page but the box’s visible area stops at the border.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is margin collapsing?

A

When vertical margins of adjacent block-level elements combine (collapse) into a single margin equal to the larger of the two, rather than adding together.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the difference between block boxes and inline boxes?

A

Block boxes break onto a new line and respect width/height. Inline boxes flow within text and don’t respect width/height (only horizontal padding/margin/border push other elements).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you make an inline element respect vertical margin, padding, and border?

A

Set display: inline-block — it stays in the inline flow but the block-direction spacing is respected.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the outer display type of a box?

A

It determines how the box participates in flow layout — either block (breaks onto new line, fills available width) or inline (flows with text).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the inner display type of a box?

A

It determines how children inside the box are laid out, e.g. display: flex sets the inner type to flex while keeping the outer type as block.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In the standard box model, if width is 350px, padding is 25px, and border is 5px, what is the total horizontal space?

A

410px — 350 + 25 + 25 + 5 + 5. Padding and border are added to both sides.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

In the alternative (border-box) model with the same values, what is the total horizontal space?

A

350px — the specified width already includes padding and border. The content area shrinks to 290px.

17
Q

Does the background extend under the border by default?

A

Yes. The background extends to the outer edge of the border (underneath it in z-ordering). This can be changed with the background-clip property.

18
Q

For non-replaced inline elements, what determines the contribution to line height?

A

The line-height property, even though padding and border are still visually rendered around the content.

19
Q

What properties can you use to size the content area?

A

width, min-width, max-width, height, min-height, and max-height.

20
Q

When is box-sizing: content-box actually useful?

A

When using position: relative or absolute, because positioning offsets stay relative to the content and remain independent of border/padding changes.