0
0
CSSmarkup~20 mins

Visibility property in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Visibility Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What happens when visibility is set to hidden?
Consider a block element styled with visibility: hidden;. What will you see in the browser?
CSS
<style>div { width: 100px; height: 100px; background: red; visibility: hidden; }</style><div></div>
AThe element is invisible but still takes up space on the page.
BThe element disappears and the space it occupied collapses.
CThe element becomes transparent but can still be clicked.
DThe element is removed from the DOM.
Attempts:
2 left
💡 Hint
Think about whether the element's space remains reserved or not.
📝 Syntax
intermediate
2:00remaining
Which CSS rule correctly hides an element but keeps its space?
Select the CSS rule that hides an element visually but preserves its space in the layout.
Adisplay: none;
Bvisibility: hidden;
Copacity: 0;
Dposition: absolute; left: -9999px;
Attempts:
2 left
💡 Hint
Remember, some properties remove the element from the layout flow.
rendering
advanced
2:00remaining
What is the visual result of this CSS snippet?
Given the following HTML and CSS, what will you see in the browser?
CSS
<style>p { visibility: collapse; border: 1px solid black; }</style><p>Hello</p>
AThe paragraph is invisible but space remains.
BThe paragraph is visible with a border.
CThe paragraph is hidden and its space collapses like display:none.
DThe paragraph text is visible but border is hidden.
Attempts:
2 left
💡 Hint
Consider how visibility: collapse; behaves on block elements.
selector
advanced
2:00remaining
Which CSS selector targets only visible elements?
You want to style only elements that are visible (not hidden by visibility). Which selector works best?
A:is(:not([style*='visibility: hidden']))
B:visible
C:not([hidden])
D:where(:not([style*='visibility: hidden']))
Attempts:
2 left
💡 Hint
CSS does not have a native :visible selector, but you can use negation with :where for specificity.
accessibility
expert
2:00remaining
How does visibility: hidden; affect screen readers?
If an element has visibility: hidden;, what is the expected behavior for screen readers?
AScreen readers read the element only if it has ARIA roles.
BScreen readers read the element but do not allow interaction.
CScreen readers still read the element content aloud.
DScreen readers ignore the element completely as if it is not in the DOM.
Attempts:
2 left
💡 Hint
Think about how hidden content should be treated for accessibility.