Bird
Raised Fist0
Tailwindmarkup~20 mins

Ping animation (notifications) in Tailwind - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Ping Animation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ rendering
intermediate
2:00remaining
What will you see with this Tailwind ping animation code?
Look at this HTML snippet using Tailwind CSS classes for a ping animation on a notification dot. What is the visible effect in the browser?
Tailwind
<div class="relative flex items-center justify-center w-10 h-10 bg-gray-200 rounded-full">
  <span class="absolute inline-flex h-3 w-3 top-1 right-1">
    <span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"></span>
    <span class="relative inline-flex rounded-full h-3 w-3 bg-red-500"></span>
  </span>
</div>
AA small red dot with a fading expanding red circle around it that repeats continuously.
BA static red dot with no animation or movement visible.
CA large red circle that grows and disappears once and then stops.
DA red dot that changes color from red to blue repeatedly.
Attempts:
2 left
💡 Hint
Focus on the animate-ping class and how it affects the inner span.
❓ selector
intermediate
1:30remaining
Which Tailwind class controls the speed of the ping animation?
Given the ping animation uses the class animate-ping, which class would you add or modify to make the ping animation slower?
Aanimate-ping-slow
Bduration-3000
Cspeed-500
Ddelay-200
Attempts:
2 left
💡 Hint
Tailwind uses duration- classes to control animation speed in milliseconds.
🧠 Conceptual
advanced
2:00remaining
Why is the ping animation wrapped in two nested spans in this Tailwind example?
Consider this structure: Why are there two spans inside the outer span?
AThey are duplicates and one can be removed without effect.
BBoth spans create two overlapping ping animations for a stronger effect.
COne span is for accessibility labels, the other for animation.
DOne span creates the expanding ping effect, the other is the solid dot on top.
Attempts:
2 left
💡 Hint
Think about layering and how animations and static elements combine visually.
❓ accessibility
advanced
2:00remaining
How to improve accessibility for a ping notification dot in Tailwind?
You have a red ping dot indicating new notifications. Which addition improves screen reader accessibility?
Tailwind
<span class="relative inline-flex h-3 w-3 rounded-full bg-red-500"></span>
AAdd alt="Red dot" attribute to the span.
BAdd tabindex="-1" to make it focusable.
CAdd aria-label="New notifications" and role="status" to the span.
DNo changes needed; color alone is enough.
Attempts:
2 left
💡 Hint
Think about how screen readers get information about visual indicators.
❓ layout
expert
2:30remaining
How to position a ping notification dot at the top-right corner of a profile picture using Tailwind?
You have a profile picture inside a div with class "relative w-16 h-16 rounded-full overflow-hidden". Which code snippet correctly places a ping dot at the top-right corner overlapping the picture?
A
&lt;span class="absolute top-0 right-0 h-4 w-4"&gt;
  &lt;span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"&gt;&lt;/span&gt;
  &lt;span class="relative inline-flex rounded-full h-4 w-4 bg-green-500"&gt;&lt;/span&gt;
&lt;/span&gt;
B
&lt;span class="relative top-0 right-0 h-4 w-4"&gt;
  &lt;span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"&gt;&lt;/span&gt;
  &lt;span class="relative inline-flex rounded-full h-4 w-4 bg-green-500"&gt;&lt;/span&gt;
&lt;/span&gt;
C
&lt;span class="fixed top-0 right-0 h-4 w-4"&gt;
  &lt;span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"&gt;&lt;/span&gt;
  &lt;span class="relative inline-flex rounded-full h-4 w-4 bg-green-500"&gt;&lt;/span&gt;
&lt;/span&gt;
D
&lt;span class="absolute bottom-0 left-0 h-4 w-4"&gt;
  &lt;span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"&gt;&lt;/span&gt;
  &lt;span class="relative inline-flex rounded-full h-4 w-4 bg-green-500"&gt;&lt;/span&gt;
&lt;/span&gt;
Attempts:
2 left
💡 Hint
Remember the parent div is relative, so use absolute positioning on the dot.

Practice

(1/5)
1. What does the animate-ping class in Tailwind CSS do in a notification badge?
easy
A. Adds a shadow around the badge
B. Changes the color of the badge to red permanently
C. Makes the badge text blink on and off
D. Creates a circle that expands and fades repeatedly to show a ping effect

Solution

  1. Step 1: Understand the purpose of animate-ping

    The animate-ping class in Tailwind creates an animation where an element expands in size and fades out repeatedly.
  2. Step 2: Connect to notification badges

    This effect is used to simulate a ping or ripple effect around a notification dot, making it visually stand out.
  3. Final Answer:

    Creates a circle that expands and fades repeatedly to show a ping effect -> Option D
  4. Quick Check:

    Ping animation = expanding fading circle [OK]
Hint: Remember ping means expanding and fading circle [OK]
Common Mistakes:
  • Thinking it changes color permanently
  • Confusing ping with blinking text
  • Assuming it adds shadows
2. Which of the following is the correct Tailwind CSS syntax to create a ping animation on a small red circle?
easy
A. <div class='w-3 h-3 bg-red-500 rounded-full ping-animation'></div>
B. <span class='w-3 h-3 bg-red-500 rounded-full animate-ping'></span>
C. <span class='w-3 h-3 bg-red-500 rounded-full animate-pulse'></span>
D. <div class='w-3 h-3 bg-red-500 rounded-full animate-spin'></div>

Solution

  1. Step 1: Identify the correct Tailwind class for ping animation

    The official Tailwind class for ping effect is animate-ping. Other classes like animate-pulse or animate-spin do different animations.
  2. Step 2: Check the element and classes

    The element should have width and height (e.g., w-3 h-3), background color (e.g., bg-red-500), rounded full for circle, and animate-ping for the ping effect.
  3. Final Answer:

    <span class='w-3 h-3 bg-red-500 rounded-full animate-ping'></span> -> Option B
  4. Quick Check:

    Use animate-ping with size and color classes [OK]
Hint: Use animate-ping class for ping effect, not animate-pulse [OK]
Common Mistakes:
  • Using animate-pulse or animate-spin instead of animate-ping
  • Misspelling animate-ping as ping-animation
  • Forgetting rounded-full for circle shape
3. What will be the visual result of this code snippet?
<div class='relative'>
  <span class='absolute inline-flex h-3 w-3 rounded-full bg-green-400 opacity-75 animate-ping'></span>
  <span class='relative inline-flex rounded-full h-3 w-3 bg-green-500'></span>
</div>
medium
A. A small green dot with a larger fading green circle expanding behind it
B. Two overlapping green dots with no animation
C. A green dot that spins continuously
D. A green dot that blinks on and off

Solution

  1. Step 1: Analyze the structure and classes

    The outer div is relative, so the absolute positioned span with animate-ping will expand and fade behind the second span.
  2. Step 2: Understand the animation effect

    The first span is a green circle with opacity 75% and ping animation, so it expands and fades repeatedly behind the solid green dot.
  3. Final Answer:

    A small green dot with a larger fading green circle expanding behind it -> Option A
  4. Quick Check:

    Relative container + absolute ping behind solid dot = expanding fading circle [OK]
Hint: Ping animation needs relative parent and absolute ping span [OK]
Common Mistakes:
  • Ignoring relative positioning causing ping to misplace
  • Confusing ping with spin or blink animations
  • Not noticing opacity for fading effect
4. You wrote this code but the ping animation is not visible:
<span class='w-3 h-3 bg-red-500 rounded-full animate-ping'></span>

What is the most likely reason?
medium
A. The circle size is too big for ping animation
B. The animate-ping class is misspelled
C. The parent container is missing relative positioning
D. Tailwind CSS does not support animate-ping

Solution

  1. Step 1: Check the positioning context

    The animate-ping animation uses absolute positioning internally, so the parent must have relative to position the ping correctly.
  2. Step 2: Verify other options

    The class animate-ping is correct and supported by Tailwind. Size being too big does not hide animation. Misspelling would cause no animation but question states code as is.
  3. Final Answer:

    The parent container is missing relative positioning -> Option C
  4. Quick Check:

    Parent needs relative for ping to show [OK]
Hint: Always add relative to parent container for ping animation [OK]
Common Mistakes:
  • Forgetting to add relative to parent
  • Assuming animate-ping is unsupported
  • Changing size thinking it affects animation visibility
5. You want to create a notification icon with a red ping animation on the top-right corner of a bell icon. Which Tailwind CSS setup correctly achieves this with proper layering and positioning?
hard
A. <div class='relative inline-block'> <svg class='w-6 h-6 text-gray-700'>...bell icon...</svg> <span class='absolute top-0 right-0 inline-flex h-3 w-3 rounded-full bg-red-500 opacity-75 animate-ping'></span> <span class='absolute top-0 right-0 inline-flex h-3 w-3 rounded-full bg-red-600'></span> </div>
B. <div class='inline-block'> <svg class='w-6 h-6 text-gray-700'>...bell icon...</svg> <span class='absolute top-0 right-0 h-3 w-3 rounded-full bg-red-500 animate-ping'></span> </div>
C. <div class='relative'> <svg class='w-6 h-6 text-gray-700'>...bell icon...</svg> <span class='relative h-3 w-3 rounded-full bg-red-500 animate-ping'></span> </div>
D. <div class='relative inline-block'> <svg class='w-6 h-6 text-gray-700'>...bell icon...</svg> <span class='absolute bottom-0 left-0 h-3 w-3 rounded-full bg-red-500 animate-ping'></span> </div>

Solution

  1. Step 1: Ensure parent container is relative and inline-block

    The container must be relative to position the ping absolutely relative to the bell icon, and inline-block to size properly.
  2. Step 2: Position ping and solid dot at top-right with layering

    Use two span elements: one with animate-ping and opacity for fading effect behind a solid dot. Both positioned absolute top-0 right-0.
  3. Final Answer:

    <div class='relative inline-block'> <svg class='w-6 h-6 text-gray-700'>...bell icon...</svg> <span class='absolute top-0 right-0 inline-flex h-3 w-3 rounded-full bg-red-500 opacity-75 animate-ping'></span> <span class='absolute top-0 right-0 inline-flex h-3 w-3 rounded-full bg-red-600'></span> </div> -> Option A
  4. Quick Check:

    Relative container + absolute ping + solid dot top-right [OK]
Hint: Use two spans: ping with opacity behind solid dot, both absolute top-right [OK]
Common Mistakes:
  • Missing relative on container causing misplacement
  • Using relative instead of absolute on ping span
  • Positioning ping at wrong corner
  • Not layering ping behind solid dot
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard