0
0
CSSmarkup~20 mins

Position absolute in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Absolute Positioning Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the effect of position: absolute
What happens to an element with position: absolute inside a container without any positioning?
AIt becomes fixed to the viewport and does not move when scrolling.
BIt stays in the normal document flow and pushes other elements down.
CIt positions itself relative to the nearest positioned ancestor or the viewport if none exists.
DIt disappears from the page and is not visible.
Attempts:
2 left
💡 Hint
Think about what happens if no parent has position set.
📝 Syntax
intermediate
2:00remaining
CSS positioning syntax and effect
Given this CSS, what will be the position of the red box relative to the blue container?

.container { position: relative; width: 200px; height: 200px; background: blue; }
.box { position: absolute; top: 20px; left: 30px; width: 50px; height: 50px; background: red; }
AThe red box will be hidden behind the blue container.
BThe red box will be 20px from the top and 30px from the left inside the blue container.
CThe red box will be centered inside the blue container.
DThe red box will be 20px from the top and 30px from the left of the entire page.
Attempts:
2 left
💡 Hint
Check the container's position property.
rendering
advanced
2:30remaining
Visual stacking order with position: absolute
Consider this HTML and CSS:

<div class='parent'><div class='child1'>A</div><div class='child2'>B</div></div>
.parent { position: relative; width: 150px; height: 150px; background: lightgray; }
.child1 { position: absolute; top: 20px; left: 20px; width: 100px; height: 100px; background: red; z-index: 1; }
.child2 { position: absolute; top: 50px; left: 50px; width: 100px; height: 100px; background: blue; }

Which box will appear on top visually?
AThe red box (child1) will appear on top because it has a higher z-index.
BBoth boxes will appear side by side without overlapping.
CThe blue box (child2) will appear on top because it is declared later in the HTML.
DThe red box will be hidden behind the blue box because it has a lower z-index.
Attempts:
2 left
💡 Hint
Remember how z-index controls stacking order.
selector
advanced
2:00remaining
Selecting absolutely positioned elements with CSS
Which CSS selector will select only the elements that have position: absolute applied?
A*[style*='position: absolute']
B.absolute
C:is([style*='position: absolute'])
D:where([style*='position: absolute'])
Attempts:
2 left
💡 Hint
Think about how to select elements by inline style attribute.
accessibility
expert
3:00remaining
Accessibility considerations for absolutely positioned elements
When using position: absolute for UI elements like modals or tooltips, what is the most important accessibility practice?
AAvoid using semantic HTML elements inside absolutely positioned containers.
BHide the element from screen readers by using <code>aria-hidden='true'</code> always.
CUse <code>position: fixed</code> instead to avoid accessibility issues.
DEnsure the element is reachable and announced by screen readers using ARIA roles and keyboard focus management.
Attempts:
2 left
💡 Hint
Think about users who rely on keyboard and screen readers.