The Display Property Flashcards
1
Q
What does the display property do?
A
Determines how an elementβs box is rendered in the browser.
Can be inline, block-level, and inline-block.
2
Q
Describe inline elements.
A
- Doesnβt start on a new line and usually does not contain additional elements, but instead just contains text.
- You canβt explicitly set the width, height, margin, or padding of an inline element; instead, its dimensions are determined by how much space its contents require.
3
Q
Describe block-level elements
A
- Gets displayed on a new line (and takes up the whole available line)
- May contain additional block-level or inline elements
- And its height and width can be explicitly set.
- By default, block-level elements will take up the entire width of whatever element they appear inside of, but we can override this by explicitly setting the width or max-width property on an element.
4
Q
Describe inline-block elements.
A
- Displays inline
- CAN give it an explicit width, height, margin and padding.
- Can be a good approach when you need to create elements with a set width, but also need them to display side-by-side.
5
Q
How can you horizontally center a block-level content within some parent element?
A
margin-left: auto;
margin-right: auto
6
Q
How can you center inline elements within a block element?
A
text-align: center;