Step-by-step instructions on how to create an animation using HTML/CSS

Scroll Down

In our programming school for kids, we provide unique courses in building websites including HTML/CSS from scratch. Today we’re going to talk about a step-by-step guide on how to create captivating animations using HTML/CSS. If you’re new to programming, don’t worry – we’ve covered every step in detail!

HTML/CSS from scratch. Step 1: Preparing the HTML structure

First, create an HTML file, open it with a text editor, and add the basic elements of the HTML structure. Now we will create an animation for the div element. Add the following code:

<!DOCTYPE html>
<title>HTML/CSS animation</title>
<link rel=”stylesheet” type=”text/css” href=”styles.css”>
<div class=”animation”></div>

<script src=”script.js”></script>

Step 2: Styling with CSS

Create a CSS file named “styles.css” and save it in the same folder as the HTML file. In CSS, you can set styles for your elements. Add the following code to style your animation:

.animation {
width: 100px;
height: 100px;
background-color: red;
position: relative;
animation-name: move;
animation-duration: 2s;
animation-iteration-count: infinite;

@keyframes move {
0% {
left: 0;
top: 0;
50% {
left: 200px;
top: 0;
100% {
left: 0;
top: 0;

Step 3: Connect the JavaScript

Add JavaScript to your HTML file to trigger the animation. Create a file called “script.js” and add the following code:
// Optional: JavaScript code can be added to dynamically change the animation

Your walkthrough is now complete!

Save all the files in one folder and open the HTML file in your web browser. You should see a div moving from left to right on the screen.

You can learn to program in HTML/CSS languages from scratch in our programming courses for children from the GoMother school. Our courses give kids the opportunity to learn the basics of HTML/CSS and gain the skills to create exciting websites and animations. Our experienced teachers work with children using interesting and age-appropriate learning methods.

Don’t delay, enroll your child in GoMother’s programming courses and allow them to become future experts in the field of HTML/CSS programming and many other programming languages. Knowledge of programming will open up many opportunities for them in the future!

Register for an online lesson

Take the first step towards a successful future of your child.

Child looks up!