Design a Traffic Light Animation using HTML and CSS Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report In this article, we will explore how HTML and CSS can be utilized to create a Traffic signal animation with Red, Green, and Yellow colors. In this, we have written a code that produces a live traffic signal using HTML and CSS. The code is responsive and uses "Keyframes" for better animation control. PreviewApproachFirst, create three divs inside the container div for three signal lights.Use CSS to define the colors for each light (red, yellow, green).Align the signals in the center of the webpage.Utilize CSS keyframe animations to create the blinking effect for lights.Example: In this example, we will see the basic implementation to create a traffic signal static website by 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"> <link rel="stylesheet" href="style.css"> <title>Traffic Light Animation</title> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f0f0f0; } .traffic-signal { width: 100px; height: 300px; background-color: #333; border-radius: 10px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; } .light { width: 60px; height: 60px; border-radius: 50%; margin: 10px; transition: background-color 0.9s; } @keyframes blinkRed { 0%, 49% { background-color: red; } 50%, 100% { background-color: black; } } @keyframes blinkYellow { 0%, 49% { background-color: yellow; } 50%, 100% { background-color: black; } } @keyframes blinkGreen { 0%, 49% { background-color: green; } 50%, 100% { background-color: black; } } .red { background-color: red; animation: blinkRed 9s infinite; } .yellow { background-color: yellow; animation: blinkYellow 9s infinite; animation-delay: 3s; } .green { background-color: green; animation: blinkGreen 9s infinite; animation-delay: 6s; } </style> </head> <body> <div class="traffic-signal"> <div class="light red animate"></div> <div class="light yellow"></div> <div class="light green"></div> </div> </body> </html> Output: Output Comment More infoAdvertise with us Next Article How to Create a Dot loading Animation using HTML and CSS? S subramanyasmgm Follow Improve Article Tags : Web Technologies Geeks Premier League Web Templates Geeks Premier League 2023 Similar Reads Design a running car animation using HTML and CSS Project Introduction: In this project, we are going to implement a car running on a track using HTML and CSS with sound effects. The prerequisites of this project are HTML, CSS, and JavaScript.File structure:index.htmlstyle.cssscript.jsHTML code: In the following code, we have placed the sky div in 3 min read Design Animated Google Loader using HTML and CSS The Google Loader consists of 4 circles with blue, red, yellow, and green colors. You can easily create them using HTML and CSS, and animate them to move the same as in the final output. The animation is just translating the circle in the Y axis with .25s time delay. For non-stop and fluid animation 2 min read How to Create a Dot loading Animation using HTML and CSS? The Dot Loading animation can be used to enhance the user interface of a website, it can be added while the website loads. This animation can be easily created using HTML and CSS. HTML Code: In this section we will create the basic structure of the dot loader using a div tag which will have some spa 2 min read Design a Video Slide Animation Effect using HTML CSS and JavaScript Nowadays, Video Slide animations are very popular. In this article, we will see how to make Video Slide Animation using HTML, CSS, and JavaScript on any webpage. Below are the two steps on how to do it. It will help the beginner to build some awesome Video Slide animations using HTML, CSS, and JS by 4 min read How to bind an animation to a division element using CSS ? In this article, we will learn to bind an animation to a div tag using CSS.A div tag is used to separate the different sections of the contents of the webpage. It makes it very easy for the readers to notice the different sections of the webpage with their specific importance levels on the page. The 3 min read Text Typing Animation Effect using HTML CSS and JavaScript To create a text-typing animation effect, we will use a combination of HTML structure, CSS animations, and JavaScript logic to create the typing and deleting text like effect.HTML<!-- index.html --> <html> <head> <link rel="stylesheet" href="styles.css"> </head> <bod 2 min read Like