0
0
CSSmarkup~20 mins

Display property in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Display Property Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
rendering
intermediate
2:00remaining
What will be the layout of the boxes?
Given the CSS below, how will the three colored boxes be arranged in the browser?
CSS
div.box {
  width: 5rem;
  height: 5rem;
  margin: 0.5rem;
}
#box1 {
  background-color: red;
  display: inline-block;
}
#box2 {
  background-color: blue;
  display: inline-block;
}
#box3 {
  background-color: green;
  display: block;
  width: 100%;
}
ARed and green boxes side by side; blue box below taking full width.
BAll three boxes appear stacked vertically, each taking full width.
CRed and blue boxes appear side by side on the same line; green box appears below them, taking full width.
DAll three boxes appear side by side on the same line.
Attempts:
2 left
💡 Hint
Remember that 'inline-block' elements sit next to each other horizontally, while 'block' elements take full width and start on a new line.
🧠 Conceptual
intermediate
1:30remaining
Which display value makes an element ignore width and height?
Which display property value causes an element to ignore its width and height settings and only take up as much space as its content?
Ainline
Bblock
Cflex
Dgrid
Attempts:
2 left
💡 Hint
Think about inline elements like <span> that wrap tightly around their text.
selector
advanced
2:30remaining
Which CSS selector targets only block elements?
Given multiple elements with different display values, which CSS selector will style only those with display: block;?
A*[style*='display: block']
B:has(display: block)
C:where(block)
D:is(div, p, section)
Attempts:
2 left
💡 Hint
CSS cannot directly select elements by computed style, but can select by attribute values.
layout
advanced
2:30remaining
How does display: contents; affect layout?
What is the visual effect of applying display: contents; to a container element?
AThe container becomes a flex container, arranging children in a row.
BThe container becomes invisible and its children are hidden as well.
CThe container becomes a block-level element with a border around its children.
DThe container disappears visually but its children remain visible and behave as if they were direct children of the container's parent.
Attempts:
2 left
💡 Hint
Think of the container as a ghost that lets its children show up directly in its place.
accessibility
expert
3:00remaining
What accessibility issue can arise from using display: none;?
Which of the following is a true statement about using display: none; on elements regarding accessibility?
AElements with <code>display: none;</code> are hidden visually but still focusable by keyboard navigation.
BElements with <code>display: none;</code> are hidden visually and also removed from the accessibility tree, so screen readers ignore them.
CElements with <code>display: none;</code> remain visible to screen readers but hidden visually.
DElements with <code>display: none;</code> become semi-transparent but remain interactive.
Attempts:
2 left
💡 Hint
Think about whether hidden elements can be read aloud by screen readers.