<!doctype html>
<html>
	<head>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link href="/assets/reset.css" rel="stylesheet">
		<link href="setup.css" rel="stylesheet">
		<link href="style.css" rel="stylesheet">
		<script defer src="script.js"></script>
	</head>
	<body>
		<section>
			<p>I’ve just added some text here to have another element, and also added some CSS to style it a bit—nothing too fancy.</p>
		</section>
		<button id="switch">Click here!</button>
	</body>
</html>

		
index.html
			// Set up our variables.
let highlightClass = 'highlight' // “Strings” (like this class name) are wrapped in quotes.
let textBlock = document.querySelector('section') // This can use any CSS selector.
let switchButton = document.querySelector('#switch') // But use `id` for a singular thing.

switchButton.addEventListener('click', () => { // “Listen” for clicks.
	textBlock.classList.toggle(highlightClass) // Toggle the class!
})

		
script.js
			html, body { block-size: 100%; }

body {
	--base: 1rem;

	display: grid;
	font-family: sans-serif;
	padding: var(--base);
	place-content: center;
	place-items: center;
	row-gap: var(--base);
}

button {
	background-color: deepskyblue;
	border-radius: calc(var(--base) / 2);
	cursor: pointer; /* Show the Mickey-Mouse hand! */
	padding: calc(var(--base) / 2);
}

		
setup.css
			section { /* Initial state, without the class. */
	background-color: gold;
	padding: calc(var(--base) / 2);
	transition: all 1s ease-in-out; /* Transition everything. */
	will-change: transform; /* Improves the aliasing! */

	&.highlight { /* When the class is applied with JS! */
		background-color: aquamarine;
		transform: rotate(5deg);
	}
}

		
style.css