The box model Flashcards

1
Q

What is the key thing to always remember when writing CSS (concerning box model) ?

A

Everything displayed by CSS is a box. Whether that’s a box that uses border-radius to look like a circle, or even just some text: the key thing to remember is that it’s all boxes.

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

What is extrinsic sizing ?

A

Extrinsic sizing is the explicit control of the size of a box using properties like width, border, etc. and assign them fixed or relative values (but not relatives to the content of that box).

With extrinsic sizing the box try to resize its content, so that the content fits into it. It does not always work, an overflow can therefore happen.

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

What is intrinsic sizing ?

A

Intrinsic sizing is when the size of the box is defined/influenced by its content. The box is more flexible and fit around its content.

The box resize itself depending of its content, rather than trying to resize its content.

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

what does the below line instruct when applied to a box ?

width: min-content

A

The min-content keyword tells the box to only be as wide as the intrinsic minimum width of its content.

It is intrinsic sizing.

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

What is an overflow ?

A

An overflow happen when a content of a box is bigger than the extrinsic size of this box. Overflow can be controlled with the css property: ‘overflow’

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

From inside to outside, what are the distinct area of a box ?

A

The content box
The padding box
The border box
The margin box.

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

How to add a scrollbar to a box

A

overflow: scroll

or

overflow: auto

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

Describe what is the content-box area ?

A

It is the area that the content lives in. this content can control the size of its parent, so is usually the most variably sized area.

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

Describe what is the padding-box area ?

A

The padding box surrounds the content box and is the space created by the padding property.

The background of the box will be visible in the space that it creates. If our box has overflow rules set, such as overflow: auto or overflow: scroll, the scrollbars will occupy this space too.

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

Describe what is the border-box area ?

A

The border box surrounds the padding box and its space is occupied by the border value. The border box is the bounds of your box and the border edge is the limit of what you can visually see. The border property is used to visually frame an element.

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

Describe what is the margin-box area ?

A

The final area, the margin box, is the space around your box, defined by the margin rule on your box. Properties such as outline and box-shadow occupy this space too because they are painted on top, so they don’t affect the size of our box. You could have an outline-width of 200px on our box and everything inside and including the border box would be exactly the same size.

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

What is the difference between inline and inline-block ?

A

An inline element has block margin, but other elements won’t respect it. Use inline-block, and those elements will respect the block margin, while the element maintains most of the same behaviors it had as an inline element.

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

What is the difference between inline and block ?

A

A block item will, by default, fill the available inline space, whereas a inline and inline-block elements will only be as large as their content.

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

What does the property content-box do ?

A

content-box tells our box how to calculate its box size. By default, all elements have the following user agent style:

box-sizing: content-box;

Having “content-box” as the value of box-sizing means that when you set dimensions, such as a width and height, they will be applied to the content box. If you then set padding and border, these values will be added to the content box’s size.

Having “border-box” as the value of box-sizing tells CSS to apply the width to the border box instead of the content box. This means that our border and padding get pushed in.

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