Random Quote Generator: Display a New Quote Every Click
What you are building
A Random Quote Generator shows a new quote every time the visitor presses a button. It is a small project, but it touches all three front-end languages at once, which makes it a good first thing to build.
The three parts
1. HTML lays out the elements the visitor sees and gives them IDs so the script can find them.
2. CSS handles colour, spacing and the button states.
3. JavaScript picks a random item from an array and writes it into the page.
Live demo
Press the button to see a quote.
The full code
Everything below is one self-contained file. Copy it into a .html file, or into a Blogger HTML widget, and it runs as-is.
How each part works
1. HTML: the structure
Three elements do all the work. A paragraph with id="quote" holds the quote text, a second paragraph with id="author" holds the attribution, and a button triggers the change. The IDs matter because they are how JavaScript locates the elements it needs to update.
2. CSS: the appearance
The card gets padding, rounded corners and a soft shadow so it reads as a distinct panel. Flexbox on body centres it in the viewport. The button has a hover state and a :focus-visible state, so it responds to a mouse and to keyboard tabbing.
3. JavaScript: the behaviour
The quotes live in an array of objects, each with a text and an author. Math.random() returns a decimal between 0 and 1; multiplying by quotes.length and passing the result through Math.floor() gives a valid array index. Writing to textContent then swaps the text in the page.
Two details worth copying into your own projects. First, the click is wired with addEventListener rather than an inline onclick attribute, which keeps behaviour out of the markup. Second, the script remembers the last index it used and re-rolls if it lands on the same one, so a click never appears to do nothing.
Ways to extend it
Categories. Add a category field to each object and filter the array before picking.
Animation. Toggle a CSS class on the card to fade the new quote in.
A live API. Replace the array with fetch() against a quotes API so the list is never exhausted.
Sharing. Build an X or Bluesky share link from the current quote text.

If you have any doubts, Please let me know