Text Animation with changing the color of the text using HTML and CSS Last Updated : 16 Jan, 2024 Comments Improve Suggest changes Like Article Like Report Text animation is the creation of beautiful and colorful letters, words, and paragraphs with a decorative movable effect. The movement can be seen in some fashion within the area or across the screen following some regular pattern. The @keyframes in CSS allows defining a series of animations at specific points during an animation sequence. In this styles are declared for different stages of the animation, enabling dynamic transitions and effects. Syntax for @keyframes:@keyframes animationname {keyframes-selector {css-styles;}} Approach:First, create an HTML file with a container div and two span elements for the text.Apply styles for the container, text1, and text2, setting initial appearances.Define font size, color, spacing, and positioning for text1 and text2.Use @keyframes to specify color and letter-spacing changes at different animation stages.Apply the animation to text1 within the container, creating a 3-second effect with color and letter-spacing variations.Example: HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Text Animation</title> <style> * { padding: 0; margin: 0; font-family: sans-serif; } body { background: yellowgreen; } .container { text-align: center; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 100%; } .container span { display: block; } .text1 { color: white; font-size: 70px; font-weight: 700; letter-spacing: 8px; margin-bottom: 20px; background: yellowgreen; position: relative; animation: text 3s 1; } .text2 { font-size: 30px; color: darkgreen; font-family: Georgia, serif; } @keyframes text { 0% { color: black; margin-bottom: -40px; } 30% { letter-spacing: 25px; margin-bottom: -40px; } 85% { letter-spacing: 8px; margin-bottom: -40px; } } </style> </head> <body> <div class="container"> <div class="row"> <span class="text1">Hello!</span> <span class="text2">GeeksforGeeks</span> </div> </div> </body> </html> Output: Comment More infoAdvertise with us N nehaahlawat Follow Improve Article Tags : Web Technologies Web Templates QA - Placement Quizzes-Data Interpretation Volkswagen IT Services Similar Reads How to change the color of selected text using CSS ? The colour of selected text can be easily changed by using the CSS | ::selection Selector. In the below code, we have used CSS ::selection on <h1> and <p> element and set its colour as yellow with green background. Below example implements the above approach: Example: html <!DOCTYPE h 1 min read How to Create Text Color Animation using HTML and CSS ? The text color can be changed according to the programmerâs choice using CSS @keyframes rule. In this article, we will see how to create text color animation using HTML and CSS. Preview:Approach:Create an HTML file with a centered <div> containing an <h2> element.Use CSS to reset default 1 min read How to Change the Background Color of Table using CSS? Changing the background color of a table using CSS can help improve the visual appearance of a website or web application. we will learn how to change the background color of the table using CSS with different approaches.These are the following approaches:Table of Content Using Inline CSSUsing Inter 2 min read How to Add Background Color in Input and Text Fields using CSS ? In this article, we will explore different approaches to adding background color to input and text fields using CSS. Customizing the appearance of input and text fields is an essential aspect of web design, and changing the background color is a powerful way to enhance the visual appeal of these ele 2 min read How to Change the Color of Link on Hover using CSS ? Changing the color of a link on hover can provide visual feedback to users, indicating that the link is interactive. It improves the user experience by helping users understand that the link is clickable. These are the following approaches: Table of Content Using CSS pseudo-classUsing CSS VariablesU 2 min read How to Change Background Color in HTML without CSS ? In HTML, you can change the background color of an element using the bgcolor attribute. However, it's important to note that the bgcolor attribute is deprecated in HTML5 and should be avoided in favor of using CSS for styling. This article will cover various methods to change the background color of 2 min read Like