How To Create Text Typing Animation using HTML & CSS

How To Create Text Typing Animation using HTML & CSS

Text Typing Animation or typewriter makes the homepage of any website much more beautiful and attractive. There are many ways to make the homepage interesting, among them CSS text typing is a significant one. If you are worried about wordpress hosting then ToggleBox site will help you.

CSS Typewriter You may have seen many types of portfolios website. Where a text is being typed repeatedly. It easily attracts the attention of the user.

How To Create Text Typing Animation using HTML & CSS

In this article, I have shown you how to create a text typing animation using HTML and CSS code.
Of course, this is multiline text typing which means there will be a lot of text being typed over and over again.

CSS Text Typing Animation

This type of typewriter effect can be used on your personal site or business website. Where you can show your own experience or product name by typing repeatedly through animation.

As you can see in the picture above this is a simple typewriter where I have fixed some text and typed a bit repetitive. This is not the first time I have shown you many more types of typewriter designs. But in that case, I took the help of JavaScript for multiple text types.

If you are a beginner, there is no reason to worry. Here I am going to show you an animation of Multiple Text Typing using Pure CSS. Below I have given a live demo that will help you know how it works.

See the Pen
Text Typing Animations
by Foolish Developer (@fghty)
on CodePen.

If you want to get the source code, you can use the download button at the bottom of the article. 

How to Create a Text Typing Animation in CSS

Below I have shared the complete tutorial on how it is made for you. Before sharing the tutorial, let me tell you something about this Text Typing Animation Effect

First I designed the webpage. Then here I have used some text which is in a completely fixed state and the rest has used a lot of text which will be typed in multiple ways. Of course, there is a cursor that makes this animation even more interesting.

Step 1: Design the web page

I designed the webpage using the following CSS codes. Here I have used black as the background color of the web page.

body {
  font-size:40px;
  margin: 100px auto;
  margin-left: 50px;
  color: white;
  background: #191d21;
  font-family: sans-serif;
}
Design the web page

Step 2: Add text to Typewriter

I have added the text using the following HTML codes. The color of the tests typed here is green. I have used overflow hidden for only one text to be seen. Overflow Hidden helps to see only one of the typed text and hide the rest.

I am a <span class=”type”>
    <span>
    <span>Developer</span>
    <span>Web Designer</span>
    <span>Blogger</span>
    <span>YouTuber</span>
    </span>
</span>
Add text to Typewriter
.type {
  display:inline-block;
  vertical-align: bottom;
}
.type > span {
  color: #14f3db;
  display:grid;
  overflow: hidden;
  height:1.2em;
}
Create Text Typing Animation using HTML & CSS

Step 3: Add animation to CSS text typing

Now I have added animation using the following CSS. I have used three codes for animation here. First I gave the animation in the cursor. Then I used animation in the text. 

Here you will have 2 seconds to type each text. It will take two seconds to remove it again. At the end of it all, I used 16 seconds for the complete typing animation. Since I have used four texts here and it will take 4 seconds for each text to be typed and removed. I have used infinite here so that this method continues till infinity time.

.type span span {
  width:0%;
  max-width:max-content;
  overflow: hidden;
  height:inherit;
  word-break:break-all;
  animation:
    c 0.5s infinite steps(1),
    t 2s linear infinite alternate,
    m 16s steps(4) infinite;
}
.type span span:before {
  content:” “;
  display:inline-block;
}

Step 4: Enable text typing animation 

Above we added animation but we need to use @keyframes to make it work.
I first executed the text using @keyframes. At 90-100% of the total time (2 seconds) we will see the text. It will start to be seen from 0% to 90% and we will see it completely.

@keyframes t{
  90%,100% {width:100%}
}

 I have executed the cursor using the following CSS codes. The cursor will be seen every 0.5 seconds and will be hidden again.

@keyframes c{
  0%,100%{box-shadow:5px 0 0 #0000}
  50%    {box-shadow:5px 0 0 white}
}
@keyframes m{
  100% {transform:translateY(-400%)}
}
Text Typing Animation using HTML & CSS

Hopefully from this tutorial, you have learned how to create text typing animations using only HTML and CSS code. This tutorial also shows you how to type multiple texts. Please comment on how you like it.