Typing Effect | Css
Tags: css, webdev, design, html
Published: 2022-01-20 06:45:50

## In This Blog , You Will Learn To Create Typing Effect In Css 😲 .

**Get Ready 🚀**

**1. Html**

```html
<div class="illustration-editor">
  <div class="code-blocks">
    <div class="code code-html">
      <header>
        <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.9999 6.675L13.1999 6.075C12.9999 5.975 12.8999 5.775 12.9999 5.675L13.8999 3.975C14.4999 2.775 13.1999 1.475 11.9999 2.075L10.2999 2.975C10.1999 3.075 9.9999 2.975 9.8999 2.775L9.2999 0.975C8.8999 -0.325 7.0999 -0.325 6.6999 0.975L6.0999 2.775C5.9999 2.975 5.7999 3.075 5.6999 2.975L3.9999 2.075C2.7999 1.475 1.4999 2.775 2.0999 3.975L2.9999 5.675C3.0999 5.775 2.9999 5.975 2.7999 6.075L0.999902 6.675C-0.300098 7.075 -0.300098 8.975 0.999902 9.375L2.7999 9.975C2.9999 9.975 3.0999 10.175 2.9999 10.275L2.0999 11.975C1.4999 13.175 2.7999 14.475 3.9999 13.875L5.6999 12.975C5.8999 12.875 6.0999 12.975 6.0999 13.175L6.6999 14.975C7.0999 16.275 8.9999 16.275 9.3999 14.975L9.9999 13.175C10.0999 12.975 10.2999 12.875 10.3999 12.975L12.0999 13.875C13.2999 14.475 14.5999 13.175 13.9999 11.975L12.9999 10.275C12.8999 10.075 12.9999 9.875 13.1999 9.875L14.9999 9.275C16.2999 8.875 16.2999 7.075 14.9999 6.675ZM7.9999 10.375C6.6999 10.375 5.5999 9.275 5.5999 7.975C5.5999 6.675 6.6999 5.575 7.9999 5.575C9.2999 5.575 10.3999 6.675 10.3999 7.975C10.3999 9.275 9.2999 10.375 7.9999 10.375Z" fill="#4C4F5A"/></svg>
<h1>HTML</h1>
        <svg width="16" height="8" viewBox="0 0 16 8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.7089 7.65105L14.8704 2.02908C15.1112 1.80937 15.2528 1.51212 15.2528 1.18902C15.2528 0.865913 15.1112 0.56866 14.8704 0.348951C14.6296 0.129241 14.3038 0 13.9497 0C13.5956 0 13.2698 0.129241 13.029 0.348951L7.75989 5.1567L2.49077 0.348951C2.24998 0.129241 1.9242 0 1.57009 0C1.21598 0 0.890202 0.129241 0.649409 0.336026C0.380287 0.568659 0.252808 0.878837 0.252808 1.18902C0.252808 1.48627 0.380286 1.78352 0.621079 2.02908C2.23581 3.51535 6.42844 7.3538 6.71173 7.6252L6.74006 7.65105C7.24998 8.11632 8.19898 8.11632 8.7089 7.65105Z" fill="#4C4F5A"/></svg>
      </header>
      <div class="code-content">
        <code>
          <span class="c-r">&lt;div</span> <span class="c-y">class</span><span class="c-w">=</span><span class="c-g">"rect"</span><span class="c-r">&gt;&lt;/div&gt;</span></div>
        </code>
      </div>
    </div>
    <div class="code code-css">
      <header>
        <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.9999 6.675L13.1999 6.075C12.9999 5.975 12.8999 5.775 12.9999 5.675L13.8999 3.975C14.4999 2.775 13.1999 1.475 11.9999 2.075L10.2999 2.975C10.1999 3.075 9.9999 2.975 9.8999 2.775L9.2999 0.975C8.8999 -0.325 7.0999 -0.325 6.6999 0.975L6.0999 2.775C5.9999 2.975 5.7999 3.075 5.6999 2.975L3.9999 2.075C2.7999 1.475 1.4999 2.775 2.0999 3.975L2.9999 5.675C3.0999 5.775 2.9999 5.975 2.7999 6.075L0.999902 6.675C-0.300098 7.075 -0.300098 8.975 0.999902 9.375L2.7999 9.975C2.9999 9.975 3.0999 10.175 2.9999 10.275L2.0999 11.975C1.4999 13.175 2.7999 14.475 3.9999 13.875L5.6999 12.975C5.8999 12.875 6.0999 12.975 6.0999 13.175L6.6999 14.975C7.0999 16.275 8.9999 16.275 9.3999 14.975L9.9999 13.175C10.0999 12.975 10.2999 12.875 10.3999 12.975L12.0999 13.875C13.2999 14.475 14.5999 13.175 13.9999 11.975L12.9999 10.275C12.8999 10.075 12.9999 9.875 13.1999 9.875L14.9999 9.275C16.2999 8.875 16.2999 7.075 14.9999 6.675ZM7.9999 10.375C6.6999 10.375 5.5999 9.275 5.5999 7.975C5.5999 6.675 6.6999 5.575 7.9999 5.575C9.2999 5.575 10.3999 6.675 10.3999 7.975C10.3999 9.275 9.2999 10.375 7.9999 10.375Z" fill="#4C4F5A"/></svg>
<h1>CSS</h1>
        <svg width="16" height="8" viewBox="0 0 16 8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.7089 7.65105L14.8704 2.02908C15.1112 1.80937 15.2528 1.51212 15.2528 1.18902C15.2528 0.865913 15.1112 0.56866 14.8704 0.348951C14.6296 0.129241 14.3038 0 13.9497 0C13.5956 0 13.2698 0.129241 13.029 0.348951L7.75989 5.1567L2.49077 0.348951C2.24998 0.129241 1.9242 0 1.57009 0C1.21598 0 0.890202 0.129241 0.649409 0.336026C0.380287 0.568659 0.252808 0.878837 0.252808 1.18902C0.252808 1.48627 0.380286 1.78352 0.621079 2.02908C2.23581 3.51535 6.42844 7.3538 6.71173 7.6252L6.74006 7.65105C7.24998 8.11632 8.19898 8.11632 8.7089 7.65105Z" fill="#4C4F5A"/></svg>
      </header>
      <div class="code-content">
        <code>
          <p class="line-1"><span class="c-y">.rect</span> <span>{</span></p><br/><p class="line-2"><span class="c-p">background</span><span>:</span> <span class="c-y">linear-gradient</span>( </p><br/><p class="line-3"><span class="c-o">-119deg</span>,</p><br/><p class="line-4"><span class="c-y">$gray</span> <span class="c-o">0%</span>,</p><br/><p class="line-5"><span class="c-y">$dark-gray</span> <span class="c-o">100%</span>);}</p>
        </code>
      </div>
    </div>
    <div class="code code-js">
      <header>
        <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.9999 6.675L13.1999 6.075C12.9999 5.975 12.8999 5.775 12.9999 5.675L13.8999 3.975C14.4999 2.775 13.1999 1.475 11.9999 2.075L10.2999 2.975C10.1999 3.075 9.9999 2.975 9.8999 2.775L9.2999 0.975C8.8999 -0.325 7.0999 -0.325 6.6999 0.975L6.0999 2.775C5.9999 2.975 5.7999 3.075 5.6999 2.975L3.9999 2.075C2.7999 1.475 1.4999 2.775 2.0999 3.975L2.9999 5.675C3.0999 5.775 2.9999 5.975 2.7999 6.075L0.999902 6.675C-0.300098 7.075 -0.300098 8.975 0.999902 9.375L2.7999 9.975C2.9999 9.975 3.0999 10.175 2.9999 10.275L2.0999 11.975C1.4999 13.175 2.7999 14.475 3.9999 13.875L5.6999 12.975C5.8999 12.875 6.0999 12.975 6.0999 13.175L6.6999 14.975C7.0999 16.275 8.9999 16.275 9.3999 14.975L9.9999 13.175C10.0999 12.975 10.2999 12.875 10.3999 12.975L12.0999 13.875C13.2999 14.475 14.5999 13.175 13.9999 11.975L12.9999 10.275C12.8999 10.075 12.9999 9.875 13.1999 9.875L14.9999 9.275C16.2999 8.875 16.2999 7.075 14.9999 6.675ZM7.9999 10.375C6.6999 10.375 5.5999 9.275 5.5999 7.975C5.5999 6.675 6.6999 5.575 7.9999 5.575C9.2999 5.575 10.3999 6.675 10.3999 7.975C10.3999 9.275 9.2999 10.375 7.9999 10.375Z" fill="#4C4F5A"/></svg>
<h1>JS</h1>
        <svg width="16" height="8" viewBox="0 0 16 8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.7089 7.65105L14.8704 2.02908C15.1112 1.80937 15.2528 1.51212 15.2528 1.18902C15.2528 0.865913 15.1112 0.56866 14.8704 0.348951C14.6296 0.129241 14.3038 0 13.9497 0C13.5956 0 13.2698 0.129241 13.029 0.348951L7.75989 5.1567L2.49077 0.348951C2.24998 0.129241 1.9242 0 1.57009 0C1.21598 0 0.890202 0.129241 0.649409 0.336026C0.380287 0.568659 0.252808 0.878837 0.252808 1.18902C0.252808 1.48627 0.380286 1.78352 0.621079 2.02908C2.23581 3.51535 6.42844 7.3538 6.71173 7.6252L6.74006 7.65105C7.24998 8.11632 8.19898 8.11632 8.7089 7.65105Z" fill="#4C4F5A"/></svg>
      </header>
      <div class="code-content">
        <code>
          <span class="c-y">var</span> <span class="c-b">colors</span> = [<span class="c-g">“#74B087”</span>, <span class="c-g">“#DE7300”</span>, <span class="c-g">“#74B087”</span>];<br/><br/>
          <span class="c-c">// Do the thing</span><br/>
          <span class="c-y">function</span> <span class="c-b">animate</span>() {}
        </code>
    </div>
  </div>
  <div class="editor-block"></div>
</div>
```

**2. Css**

```css
html, body {
  height: 95%;
}

body {
  background: linear-gradient(135deg, #000111 0%, #000000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.illustration-editor {
  margin-top: -2rem;
  margin-right: -10rem;
  display: grid;
  grid-template-rows: 24px auto;
  justify-items: center;
  position: relative;
}

.code {
  position: absolute;
  width: 290px;
  height: 145px;
  background: #1D1E22;
  box-shadow: 0px 4px 30px rgba(0, 0, 0, 0.5);
  border-radius: 6px;
  z-index: 5;
}
.code header {
  display: grid;
  grid-template-columns: 36px auto 36px;
  align-items: center;
}
.code header svg {
  margin: 10px;
}
.code header h1 {
  font-family: Lato, sans-serif;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 1.57px;
  color: #C5C8D4;
  margin: 0;
}
.code-html {
  left: -100px;
  top: 40px;
}
.code-css {
  left: -25px;
  top: 200px;
}
.code-js {
  left: -175px;
  top: 360px;
}
.code .code-content {
  margin: 0 10px 10px;
  color: white;
}
.code .code-content .c-r {
  color: #A88038;
}
.code .code-content .c-o {
  color: #DE7300;
}
.code .code-content .c-y {
  color: #E1CA72;
}
.code .code-content .c-g {
  color: #74B087;
}
.code .code-content .c-p {
  color: #9F8198;
}
.code .code-content .c-b {
  color: #7A99AD;
}
.code .code-content .c-c {
  color: #666666;
}
.code-css .code-content code .line-1 {
  width: 0%;
  margin: 0;
  border-right: 0.15em solid transparent;
  overflow: hidden;
  display: inline-block;
  white-space: nowrap;
}
.code-css .code-content code .line-2 {
  width: 0%;
  margin: 0;
  border-right: 0.15em solid transparent;
  overflow: hidden;
  display: inline-block;
  white-space: nowrap;
}
.code-css .code-content code .line-3 {
  width: 0%;
  margin: 0;
  border-right: 0.15em solid transparent;
  overflow: hidden;
  display: inline-block;
  white-space: nowrap;
}
.code-css .code-content code .line-4 {
  width: 0%;
  margin: 0;
  border-right: 0.15em solid transparent;
  overflow: hidden;
  display: inline-block;
  white-space: nowrap;
}
.code-css .code-content code .line-5 {
  width: 0%;
  margin: 0;
  border-right: 0.15em solid transparent;
  overflow: hidden;
  display: inline-block;
  white-space: nowrap;
}
.code-css .code-content code .line-1 {
  animation: typing-1 3s 0s steps(30, end) forwards, cursor 1s linear 0s 3;
}
.code-css .code-content code .line-2 {
  animation: typing-2 3s 3s steps(30, end) forwards, cursor 1s linear 3s 3;
}
.code-css .code-content code .line-3 {
  animation: typing-3 3s 6s steps(30, end) forwards, cursor 1s linear 6s 3;
}
.code-css .code-content code .line-4 {
  animation: typing-4 3s 9s steps(30, end) forwards, cursor 1s linear 9s 3;
}
.code-css .code-content code .line-1, .code-css .code-content code .line-3, .code-css .code-content code .line-4 {
  animation-duration: 1s;
  animation-timing-function: steps(10, end);
}
.code-css .code-content code .line-5 {
  border-color: transparent;
  animation: typing-5 3s 12s steps(30, end) forwards, cursor-persist 1s linear 12s infinite;
}
.code-css .code-content code .line-2 {
  margin-left: 2rem;
}
.code-css .code-content code .line-3, .code-css .code-content code .line-4, .code-css .code-content code .line-5 {
  margin-left: 4rem;
}

.editor-block {
  position: relative;
  display: block;
  width: 500px;
  height: 421px;
  background: linear-gradient(109.61deg, #4C4F5A 4.26%, #202125 84.84%);
  border-radius: 10px;
}

@keyframes typing-1 {
  from {
    width: 0;
  }
  to {
    width: 60px;
  }
}
@keyframes typing-2 {
  from {
    width: 0;
  }
  to {
    width: 220px;
  }
}
@keyframes typing-3 {
  from {
    width: 0;
  }
  to {
    width: 70px;
  }
}
@keyframes typing-4 {
  from {
    width: 0;
  }
  to {
    width: 75px;
  }
}
@keyframes typing-5 {
  from {
    width: 0;
  }
  to {
    width: 141px;
  }
}
@keyframes cursor {
  from, to, 20%, 80% {
    border-color: transparent;
  }
  25%, 75% {
    border-color: white;
  }
}
@keyframes cursor-persist {
  from, 45% {
    border-color: transparent;
  }
  50%, to {
    border-color: white;
  }
}
```

And Your Code Will Look Like This 👇

![Preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/05rlgn857nnfdbkjuktn.png)