1D0-720 · Question #95
Which CSS property is used to set the layout of an element as a flexible box?
The correct answer is A. display: flex. display: flex; activates the Flexbox layout model on an element, making it a flex container whose children automatically become flex items that can be arranged, aligned, and distributed in flexible ways. Why the distractors are wrong: B. position: absolute; - removes an element…
Question
Which CSS property is used to set the layout of an element as a flexible box?
Options
- Adisplay: flex;
- Bposition: absolute;
- Cdisplay: block;
- Dlayout: flexible;
How the community answered
(41 responses)- A93% (38)
- C2% (1)
- D5% (2)
Explanation
display: flex; activates the Flexbox layout model on an element, making it a flex container whose children automatically become flex items that can be arranged, aligned, and distributed in flexible ways.
Why the distractors are wrong:
- B.
position: absolute;- removes an element from the normal document flow and positions it relative to its nearest positioned ancestor; it has nothing to do with flexible layouts. - C.
display: block;- makes an element a block-level box (stacking vertically, taking full width), but does not enable any flexible or directional alignment features. - D.
layout: flexible;- this property does not exist in CSS; it's a plausible-sounding decoy.
Memory tip: Think "flex goes with display" - just like display: grid; enables Grid layout, display: flex; enables Flexbox. The keyword always pairs with the display property, and flex is the exact value name used in the spec.
Topics
Community Discussion
No community discussion yet for this question.