VOOZH about

URL: https://www.geeksforgeeks.org/css/how-to-create-text-fill-animation-using-css/

⇱ How to create text-fill animation using CSS ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to create text-fill animation using CSS ?

Last Updated : 15 Jul, 2025

A text-fill animation using CSS is a visual effect where the content of text gradually fills with a color, gradient, or pattern over time. This animation can create dynamic, eye-catching effects for headings or titles by adjusting properties like background-size, clip-path, or keyframe animations.

Approach:

  • Position Text: Use absolute positioning to center the text vertically and horizontally on the page.
  • Create Overlay: The ::before pseudo-element overlays the original text with a different color.
  • Text Content: Use content: attr(data-text) to duplicate the original text for the overlay effect.
  • Hidden Overlay: Initially, set the overlay's width to 0% for a hidden state.
  • Reveal on Hover: Increase the overlay's width to 100% on hover using a smooth transition.

Example: Here we are following the above-explained approach.

Output:

👁 Image
Comment
Article Tags: