M2- Box model introduction Flashcards

1
Q

What is the CSS box model?

A

The CSS box model is a concept used to control the layout of HTML elements. It treats each element as a rectangular box that consists of content, padding, border, and margin.

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

What are the four parts of the box model?

A

1) Content: The actual text or image.
2) Padding: The space between the content and the border.
3) Border: The line surrounding the padding and content.
4) Margin: The space outside the border, separating the element from others.

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

How does the content size affect the box model?

A

The content size is the width and height of the actual text or image. By default, browsers calculate this size based on the content itself, but developers can adjust it using CSS properties such as width, height, min-width, and max-width.

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

What is padding and how is it calculated?

A

Padding is the space between the content and the border. Its size is calculated as:

  • Padding Box Width: Content width + padding-left + padding-right.
  • Padding Box Height: Content height + padding-top + padding-bottom.

CSS properties for padding include padding-top, padding-bottom, padding-left, and padding-right.

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

How do you set a border in CSS?

A

The border surrounds the padding and content. Its size is known as the border box width and height. You can set different border styles like solid or dashed, and adjust thickness using properties like border-width with values such as thin, medium, or thick.

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

How can you calculate the size of the border box?

A
  • Border Box Width: Content width + padding-left + padding-right + border-left + border-right.
  • Border Box Height: Content height + padding-top + padding-bottom + border-top + border-bottom.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the margin and how is it set?

A

Margin is the space outside the border that separates the element from others. It is set using margin-top, margin-bottom, margin-left, and margin-right.

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

How do you calculate the margin box size?

A
  • Margin Box Width: Border box width + margin-left + margin-right.
  • Margin Box Width: Border box height + margin-top + margin-bottom.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you adjust these parts?

A
  • Content: You can set the size using width and height.
  • Padding: Adjust with padding-top, padding-bottom, padding-left, and padding-right.
  • Border: Set it with border-width, border-style, and border-color.
  • Margin: Adjust with margin-top, margin-bottom, margin-left, and margin-right.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you calculate the size of the whole box?

A
  • Total Width: Content width + padding left + padding right + border left + border right + margin left + margin right.
  • Total Height: Content height + padding top + padding bottom + border top + border bottom + margin top + margin bottom.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly