0
0
Tailwindmarkup~20 mins

Sticky header and footer in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sticky Layout Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
layout
intermediate
2:00remaining
Sticky Header Behavior
Given this Tailwind CSS code for a header, what will happen when you scroll the page?
Tailwind
<header class="sticky top-0 bg-white shadow p-4">Header Content</header>
AThe header stays visible at the top of the page while scrolling.
BThe header scrolls away with the page content.
CThe header becomes fixed at the bottom of the page.
DThe header disappears when scrolling down and reappears when scrolling up.
Attempts:
2 left
💡 Hint
Think about what the 'sticky' and 'top-0' classes do in Tailwind CSS.
layout
intermediate
2:00remaining
Sticky Footer Positioning
Which Tailwind CSS class combination correctly makes a footer stick to the bottom of the viewport even when the page content is short?
A<footer class="sticky bottom-0 bg-gray-200 p-4">Footer</footer>
B<footer class="absolute bottom-0 bg-gray-200 p-4">Footer</footer>
C<footer class="fixed bottom-0 w-full bg-gray-200 p-4">Footer</footer>
D<footer class="relative bottom-0 bg-gray-200 p-4">Footer</footer>
Attempts:
2 left
💡 Hint
Consider which positioning keeps the footer visible at the bottom regardless of content length.
accessibility
advanced
2:00remaining
Accessible Sticky Header
Which of these code snippets best improves accessibility for a sticky header in Tailwind CSS?
A<header class="sticky top-0 bg-white p-4" role="banner" aria-label="Main site header">Site Header</header>
B<header class="sticky top-0 bg-white p-4" tabindex="-1">Site Header</header>
C<header class="sticky top-0 bg-white p-4" aria-hidden="true">Site Header</header>
D<header class="sticky top-0 bg-white p-4" role="contentinfo">Site Header</header>
Attempts:
2 left
💡 Hint
Think about semantic roles and how screen readers identify page regions.
selector
advanced
2:00remaining
CSS Selector for Sticky Footer
Which CSS selector correctly targets only the footer element with class 'sticky-footer' to apply sticky positioning?
A#sticky-footer { position: sticky; bottom: 0; }
B.sticky-footer footer { position: sticky; bottom: 0; }
Cfooter .sticky-footer { position: sticky; bottom: 0; }
Dfooter.sticky-footer { position: sticky; bottom: 0; }
Attempts:
2 left
💡 Hint
Remember how class selectors and element selectors combine.
🧠 Conceptual
expert
3:00remaining
Sticky Header and Footer Layout Challenge
You want a page with a sticky header at the top, a sticky footer at the bottom, and a scrollable main content area between them. Which Tailwind CSS layout approach achieves this correctly?
A
&lt;div class="flex flex-col h-screen"&gt;
  &lt;header class="sticky top-0 bg-white p-4"&gt;Header&lt;/header&gt;
  &lt;main class="flex-1 overflow-auto p-4"&gt;Content&lt;/main&gt;
  &lt;footer class="sticky bottom-0 bg-gray-200 p-4"&gt;Footer&lt;/footer&gt;
&lt;/div&gt;
B
&lt;div class="flex flex-col h-screen"&gt;
  &lt;header class="fixed top-0 w-full bg-white p-4"&gt;Header&lt;/header&gt;
  &lt;main class="flex-1 overflow-auto p-4 mt-16 mb-16"&gt;Content&lt;/main&gt;
  &lt;footer class="fixed bottom-0 w-full bg-gray-200 p-4"&gt;Footer&lt;/footer&gt;
&lt;/div&gt;
C
&lt;div class="flex flex-col min-h-screen"&gt;
  &lt;header class="sticky top-0 bg-white p-4"&gt;Header&lt;/header&gt;
  &lt;main class="flex-grow overflow-auto p-4"&gt;Content&lt;/main&gt;
  &lt;footer class="sticky bottom-0 bg-gray-200 p-4"&gt;Footer&lt;/footer&gt;
&lt;/div&gt;
D
&lt;div class="grid grid-rows-[auto_1fr_auto] h-screen"&gt;
  &lt;header class="sticky top-0 bg-white p-4"&gt;Header&lt;/header&gt;
  &lt;main class="overflow-auto p-4"&gt;Content&lt;/main&gt;
  &lt;footer class="sticky bottom-0 bg-gray-200 p-4"&gt;Footer&lt;/footer&gt;
&lt;/div&gt;
Attempts:
2 left
💡 Hint
Think about how fixed positioning works and how to prevent content from hiding behind header/footer.