Documentation

Student-friendly HTML, CSS, and JavaScript reference with examples

Sections

classList.add

Adds a CSS class to an element.

const button = document.querySelector('button');

button.classList.add('active');
button.classList.add('highlight', 'large'); // Add multiple

The element now has the class and gets its styles from CSS.