Lesson 5: JavaScript

Making the Web Interactive

If HTML is the skeleton and CSS is the clothing, JavaScript (JS) is the muscles! It is the programming language that lets websites do things—like opening a menu, playing a game, or showing an alert.

[Image illustrating how HTML CSS and JavaScript work together]

A Simple Alert

One of the easiest ways to see JavaScript in action is by making the browser pop up an alert box. You can actually trigger JavaScript directly inside an HTML button using the onclick attribute.

<button onclick="alert('Go Eagles!')">Click Me!</button>

(If you write the code above in your own file and click the button, your browser will say "Go Eagles!")

Test Your Knowledge!

Challenge 1: The JS Role

If you want to make a gallery of pictures that slides to the next picture when you click an arrow, which language would you use to create that sliding action?

Click here to reveal the answer
JavaScript!

HTML just puts the picture there, and CSS makes it look nice, but JavaScript handles the click and the action.