Text Typing Animation Effect using HTML CSS and JavaScript Last Updated : 18 Nov, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report 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> <body> <div class="container"> <div class="typing"><span id="text"></span> <div class="cursor"></div> </div> </div> <script src="main.js"></script> </body> </html> CSS /* styles.css */ body { font-family: Arial, sans-serif; background-color: #a9fdf2; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: center; text-align: center; } .typing { display: inline-block; padding: 20px; font-size: 90px; color: rgba(60, 0, 255, 0.897); animation: typing 3s steps(20, end), colorChange 3s ease-in-out infinite; } .cursor { display: inline-block; width: 8px; height: 60px; background-color: rgb(204, 240, 0); animation: blink 0.7s infinite; } @keyframes typing { 0% { width: 0; } 100% { width: 100%; } } @keyframes colorChange { 0%, 100% { color: rgba(60, 0, 255, 0.897); } 50% { color: rgba(255, 5, 5, 0.897); } } @keyframes blink { 0%, 100% { background-color: transparent; } 50% { background-color: rgb(0, 0, 0); } } JavaScript //main.js let a = ["Learn DSA", "Learn JavaScript", "Learn ReactJS", "Learn JAVA"]; let ref = document.getElementById("text"); let ind = 0, cInd = 0; let remove = false; function typing() { if (ind < a.length) { let currentText = a[ind]; if (!remove && cInd < currentText.length) { ref.textContent += currentText.charAt(cInd); cInd++; setTimeout(typing, 100); } else if (remove && cInd >= 0) { ref.textContent = currentText.substring(0, cInd); cInd--; setTimeout(typing, 100); } else { remove = !remove; if (!remove) { ind = (ind + 1) % a.length; } setTimeout(typing, 1000); } } } typing(); OutputExplanationHTML Structure: The HTML contains a title and a container with a <span> element for the animated text and a <div> for the blinking cursor.CSS Styling: Styles are applied for the overall layout and animations, including a color-changing and blinking cursor effect.JavaScript Typing Logic: The JavaScript function iteratively adds and removes characters from the text using a loop to create the typing and deleting effect.Customizable Text Array: The textdata array stores phrases to be typed, and they can be easily modified to change the displayed messages.Animation Timings: The setTimeout function controls the speed of the typing and deleting animations, which can be adjusted for different effects. Comment More infoAdvertise with us Next Article Text Typing Animation Effect using HTML CSS and JavaScript G gauravggeeksforgeeks Follow Improve Article Tags : JavaScript Web Technologies Geeks Premier League JavaScript-Projects Geeks Premier League 2023 +1 More Similar Reads How to Create Text Animation Effect using JavaScript ? Creating text animations in JavaScript can add an extra layer of interactivity and engagement to a website or application. By using JavaScript, we can create text that moves, fades, changes color, or transforms in other ways. Animating text can also help convey important information or messages in a 2 min read Self-Typing Text Effect using CSS & JavaScript Self-Typing Text Effect is a type of effect in which all the alphabets of the text are revealed one by one, one after the other to give the look and feel of being typed on the screen by themselves. Even though this is a basic text effect, it is still eye-capturing and effective animation. This anima 5 min read How to make Animated Click Effect using HTML CSS and JavaScript ? In this article, we will see how to make an Animated Click Effect using HTML CSS, and JavaScript. We generally see animations on modern websites that are smooth and give users a good experience. Here, we will see when the user clicks on the button only then some animation would appear. The animation 3 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 Create a Letter-Spacing Animation Effect using HTML and CSS In this article, we are going to create a letter-spacing animation using CSS. Letter spacing is the available space between the letters in a particular word, we will walk through each step to achieve this animation effect for our web page.Approach:Initially, letter-spacing will be -15px.At 20%, lett 2 min read Like