How to use keyframes In HTML

In this, we will create a text-reveal effect by wrapping your text in a `<div>` inside a container. Apply CSS with keyframes to the container for a gradual reveal, creating a visually appealing effect. The approach is to animate frames to slowly reveal the text frame-wise.

Note: You can change the value of height and width used in each frame to reveal text differently.

Example: In this example, we will see how to create text-reveal effects using HTML and CSS.

html




< !DOCTYPE html>
    <html lang="en">
  
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" 
              content="width=device-width, initial-scale=1.0">
        <title>Text Reveal Animation</title>
        <style>
            body {
                background: green;
            }
  
            .geeks {
                width: 20%;
                top: 50%;
                position: absolute;
                left: 40%;
                border-bottom: 5px solid white;
                overflow: hidden;
                animation: animate 2s linear forwards;
            }
  
            .geeks h1 {
                color: white;
            }
  
            @keyframes animate {
                0% {
                    width: 0px;
                    height: 0px;
                }
  
                30% {
                    width: 50px;
                    height: 0px;
                }
  
                60% {
                    width: 50px;
                    height: 80px;
                }
            }
        </style>
    </head>
  
    <body>
        <div class="geeks">
            <h1>w3wiki</h1>
        </div>
    </body>
  
    </html>


Output: 

How to create text-reveal effect using HTML and CSS ?

Text-reveal is a type of effect in which all the alphabets of the text are revealed one by one in some animated way. There are uncountable ways to animate text for this effect. It is up to your creativity how you want the text to reveal. We will look at a basic and easy way to get started.

Table of Content

  • Using keyframes
  • Using Clip-path

Similar Reads

Using keyframes :

In this, we will create a text-reveal effect by wrapping your text in a `

Using Clip-path

...