webdevpuneet.com

Word Guess Game (Wordle-Style) with Daily Word & Levels

Word Guess Game (Wordle-Style) · Games · Plain HTML, CSS & JS · Live preview

CategoryGames

About this UI Snippet

Word Guess — A Wordle-Style Game with a Daily Word, 20 Levels, Hard Mode, Hints and Shareable Results

Screenshot of the Word Guess Game (Wordle-Style) snippet rendered live

Word Guess is a Wordle-style game: you have a limited number of tries to find a hidden word, and after each guess every letter is marked green (right letter, right place), yellow (the letter is in the word, but somewhere else) or grey (not in the word). This version is a complete game with real word lists, a Daily Word with a streak, 20 levels in four tiers, words of four, five and six letters, hard mode, hints, statistics and an emoji result you can copy and share. It is plain HTML, CSS and JavaScript with no libraries, images or audio files.

Scoring repeated letters correctly

The classic bug in word games is how repeated letters are coloured. scoreGuess() works in two passes. The first pass marks every exact match green and counts the letters of the answer that are still unmatched. The second pass then gives a yellow only while an unmatched copy of that letter remains. So guessing "SPEED" against "ABIDE" colours only one E, exactly as the original game does, and the on-screen keyboard keeps the best status each letter has ever had (green beats yellow beats grey).

Word lists that scale

The RAW object holds three lists, one per word length. Each has "answers" (common words that can be the hidden word) and "extra" words (valid guesses that will never be the answer, so rare words never feel unfair). A guess must be in the list, otherwise the row shakes and a message tells you. Plurals of the shorter answer lists are accepted as guesses automatically. words() normalises, de-duplicates and checks the length of every entry at start-up, so adding a word is just adding it to the string.

The same word for everyone

Levels and the Daily Word pick their answer with a small seeded random generator (mulberry32). Level i always uses the same seed, so level 7 is the same word for every player, and the Daily Word uses the day number, so everyone plays the same word on the same day. Clearing the daily word on consecutive days builds a streak, and the Practice buttons give you an endless supply of random words of any length.

Hard mode and hints

In hard mode, hardViolation() checks your guess against every earlier row: a green letter has to stay in its position, and a yellow letter has to appear in the guess (with the right number of copies). Four of the five-letter levels and the later six-letter levels force it. The Hint button tells you the letter at one position you have not found yet and shows it faintly in your next row. You get three hints per game and each one costs a star.

Stars, stats and sharing

Solving a level in the par number of guesses or fewer earns three stars, one more guess earns two, and any win earns one, minus one star when a hint was used. Solving a level unlocks the next. A statistics screen tracks games played, win rate, the current and best win streak and a guess-distribution chart that highlights your result. Copy result builds the familiar grid of green, yellow and black squares (orange and blue in high contrast mode) so you can share it without spoiling the word.

Feel and accessibility

Tiles pop as you type, the row shakes on an invalid word, tiles flip one by one to reveal their colours and bounce when you win, with matching sounds from a Web Audio synth. A high contrast colour option replaces green and yellow with orange and blue for colour-blind players. The game works with the physical keyboard and the on-screen keyboard, scales to short preview areas, and stacks on phones. Progress, statistics, the streak and your settings are saved to localStorage inside try/catch.

What's included

Features

Correct two-pass scoring of repeated letters and a keyboard that keeps the best status of every letter
Real word lists for 4, 5 and 6 letters, with common answers and extra valid guesses, checked and de-duplicated at start-up
Daily Word with a day streak, plus 20 levels in four tiers and endless practice words of any length
The same word for every player: levels and the daily word use a seeded random generator
Hard mode (forced on later levels) that checks greens stay in place and yellows are reused
Hints that reveal one letter position and show it faintly in the next row, three per game
Statistics: games played, win rate, win streak, best streak and a guess-distribution chart
Emoji result grid with a Copy result button, in classic or high contrast colours
Tile pop, shake, staggered flip and win bounce animations with Web Audio sound effects
Physical and on-screen keyboard, high contrast option, scaling to short preview areas, saved progress in localStorage inside try/catch

Step by step

How to Use

  1. 1
    Pick a level, the Daily Word or practiceThe menu shows 20 levels in four tiers: 4-letter words, 5-letter words, 5-letter words in hard mode, and 6-letter words with 7 tries. Level 1 is open at first and each solved level unlocks the next. The gold card is the Daily Word, and the Practice buttons give a random word of 4, 5 or 6 letters.
  2. 2
    Type a guessUse your keyboard or the on-screen keys, press Enter to submit and Backspace to delete. A guess has to be a real word from the list, otherwise the row shakes and a message tells you why.
  3. 3
    Read the coloursGreen means the right letter in the right place. Yellow means the letter is in the word but in a different place. Grey means it is not in the word (or all its copies are already accounted for). The on-screen keyboard keeps track of the best result for every letter.
  4. 4
    Use hard mode and hintsIn hard mode you must reuse the greens and yellows you have found. The Hint button (or the ? key) reveals one letter position and shows it faintly in the next row. You get three hints per game and each one costs a star.
  5. 5
    Earn stars and keep your streakSolve in the par number of guesses for three stars. Solve the Daily Word on consecutive days to build a streak. The result screen shows your guess-distribution chart and a Copy result button that makes a shareable emoji grid.
  6. 6
    Make it easier on the eyesThe colour button switches to a high contrast palette of orange and blue, and the sound button mutes the game. Your settings, stars and statistics are saved in this browser.

Real-world uses

Common Use Cases

Teaching a classic scoring algorithm
The two-pass scoring of repeated letters is a small but tricky algorithm that many clones get wrong. Hard mode adds a second constraint-checking exercise, and both are short enough to read in one sitting.
A daily game for a site or newsletter
A word of the day with a streak and a share grid is a proven reason to come back every day. The date-seeded word needs no backend and no stored puzzles.
Reference for word lists and validation
The answer and extra lists, the normalising loader and the automatic plurals show a practical way to keep a dictionary small while avoiding unfair rejections.
Accessible colour-based feedback
The high contrast palette, the keyboard colours that follow the board and the text messages for every rejected guess show how to make colour feedback usable for everyone.
Animating a reveal with CSS only
The flip is a CSS keyframe applied tile by tile with timers, with the colour switched at the middle of the flip. The shake, pop and bounce are all single classes.
Related: Hangman Word Guessing Game
See the Hangman Word Guessing Game for another word-guessing game with a different feedback model.
Related: Word Unscramble Puzzle Game
See the Word Unscramble Puzzle Game for a related games pattern worth pairing with this one.

Got questions?

Frequently Asked Questions

scoreGuess() uses two passes. The first marks exact matches green and counts the letters of the answer that were not matched. The second pass marks a letter yellow only while an unmatched copy remains in that count, so a letter is never marked yellow more times than it appears in the answer. This is the same rule as the original game.

Yes. Add words to the strings in the RAW object: put common words in the "a" string for that length (they can become the hidden word) and rare words in the "x" string (they are only accepted as guesses). words() filters anything that is the wrong length or not lowercase letters, so a typo cannot break the game.

A guess must be in the word list for that length, which has several thousand words. Very rare words and some inflected forms are missing, and the game tells you "is not in the word list" instead of wasting a try. You can add more words to the "x" strings.

hardViolation() compares your new guess with every earlier guess and its colours. A letter that was green has to be in the same position, and a letter that was yellow has to appear in the guess, as many times as it was marked green or yellow. If a rule is broken the row shakes and a message names the letter. Some levels force hard mode, and you can switch it on yourself before your first guess.

Each level has a par pair, for example 3 and 4 guesses. Solving within the first number gives three stars, within the second gives two and any win gives one, minus one star if you used a hint. The daily streak goes up when you solve the Daily Word on the day after your last daily solve and resets after a missed day. Statistics (games played, win rate, win streak) count every finished game.

Yes. All localStorage access is wrapped in try/catch, so a blocked storage only means that your progress is not saved, and every sound call is wrapped too. The on-screen keyboard works by touch, and on narrow screens the layout stacks and the page scrolls.

Copy & paste

Source Code

<div class="wg-fit" id="wg-fit"><div class="wg-wrap" id="wg-wrap">
  <div class="wg-panel" id="wg-panel">
    <div class="wg-hud">
      <div class="wg-hud-left">
        <span class="wg-kicker" id="wg-kicker">Word Guess</span>
        <span class="wg-name" id="wg-name">Pick a level</span>
      </div>
      <div class="wg-hud-btns">
        <button class="wg-btn-sm" id="wg-hard" type="button" aria-pressed="false" title="Hard mode: you must reuse the hints you have found">Hard mode off</button>
        <button class="wg-btn-sm" id="wg-contrast" type="button" aria-pressed="false" title="High contrast colours">Colours: classic</button>
        <button class="wg-btn-sm" id="wg-levels-btn" type="button" title="Levels (Esc)">Levels</button>
        <button class="wg-btn-sm" id="wg-mute" type="button" aria-pressed="false">Sound on</button>
      </div>
    </div>

    <div class="wg-main">
      <div class="wg-board-col"><div class="wg-board" id="wg-board" role="grid" aria-label="Guess grid"></div></div>
      <div class="wg-side">
        <div class="wg-info">
          <div class="wg-stat"><span class="wg-label">Guess</span><b id="wg-guess">0 / 6</b></div>
          <div class="wg-stat"><span class="wg-label">Letters</span><b id="wg-len">5</b></div>
          <div class="wg-stat"><span class="wg-label">Hints</span><b id="wg-hints">3</b></div>
          <button class="wg-tool" id="wg-hint" type="button"><span>&#128161;</span> Hint <em>?</em></button>
        </div>
        <p class="wg-msg" id="wg-msg">Type a word and press Enter.</p>
        <div class="wg-keys" id="wg-keys"></div>
      </div>
    </div>

    <div class="wg-overlay show" id="wg-menu">
      <p class="wg-logo">Word Guess</p>
      <p class="wg-tagline">Find the hidden word. After each guess, green means the right letter in the right place, yellow means the letter is in the word somewhere else, grey means it is not in the word.</p>
      <div class="wg-menu-row">
        <button class="wg-daily" id="wg-daily" type="button">
          <span class="wg-daily-title" id="wg-daily-title">Daily Word</span>
          <span class="wg-daily-sub" id="wg-daily-sub">One new word a day, the same for everyone</span>
        </button>
        <div class="wg-practice">
          <span class="wg-practice-label">Practice (random word)</span>
          <div><button class="wg-chip" data-len="4" type="button">4 letters</button><button class="wg-chip" data-len="5" type="button">5 letters</button><button class="wg-chip" data-len="6" type="button">6 letters</button></div>
        </div>
        <div class="wg-totals"><span><b id="wg-star-total">0</b> / 60 stars</span><span>Daily streak <b id="wg-streak">0</b></span><span id="wg-record"></span></div>
      </div>
      <div class="wg-tiers" id="wg-tiers"></div>
    </div>

    <div class="wg-overlay" id="wg-result">
      <p class="wg-result-title" id="wg-result-title">Solved!</p>
      <div class="wg-result-stars" id="wg-result-stars"><span>&#9733;</span><span>&#9733;</span><span>&#9733;</span></div>
      <p class="wg-result-sub" id="wg-result-sub"></p>
      <div class="wg-dist" id="wg-dist"></div>
      <div class="wg-result-btns">
        <button class="wg-btn" id="wg-next" type="button">Next level</button>
        <button class="wg-btn wg-btn-ghost" id="wg-retry" type="button">Play again</button>
        <button class="wg-btn wg-btn-ghost" id="wg-share" type="button">Copy result</button>
        <button class="wg-btn wg-btn-ghost" id="wg-menu-back" type="button">Levels</button>
      </div>
    </div>
  </div>
</div></div>

Extend with AI

Take This Snippet Further With AI

Paste this snippet's HTML, CSS and JS into an AI coding assistant like Claude and ask it to explain how scoreGuess() handles repeated letters in two passes, how hardViolation() counts copies of a yellow letter, and how the staggered flip animation colours each tile at the middle of the flip. It is also a good base to extend: ask for a "how many words are still possible" counter that filters the list after every guess, a solver that suggests the best next guess, a multiplayer race on the same daily word, a custom word challenge you can send as a link, or a bigger dictionary loaded on demand. You can also ask it to review the busy flag and run id that guard typing during the reveal animation.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a Wordle-style word guessing game in plain HTML, CSS and JavaScript, with no libraries, images or audio files.

Requirements:
- A grid with one row per guess and one tile per letter (4, 5 or 6 letters), plus an on-screen QWERTY keyboard and physical keyboard support (letters, Enter, Backspace). Tiles pop when typed, the row shakes for an invalid guess, tiles flip one by one to reveal green (right letter, right place), yellow (in the word, wrong place) or grey, and win tiles bounce.
- Score guesses with two passes so repeated letters are right: first mark exact matches and count the unmatched letters of the answer, then mark yellow only while an unmatched copy remains. The on-screen keys keep the best status of each letter (green over yellow over grey).
- Word lists for 4, 5 and 6 letters, each with "answers" (common words) and "extra" valid guesses, normalised and de-duplicated at start-up. Reject a guess that is too short or not in the list with a message. Accept plurals of the shorter answer lists as guesses.
- 20 levels in 4 tiers (4 letters, 5 letters, 5 letters in hard mode, 6 letters with 7 tries) defined as data, with a seeded random generator (mulberry32) choosing the answer so every player gets the same word. A Daily Word (5 letters) from the date with a day streak, and Practice buttons for random 4, 5 and 6 letter words.
- Hard mode (a toggle, forced on some levels): greens must stay in place and yellow letters must be reused with the right number of copies, otherwise the row shakes with a message.
- 3 hints per game that reveal one letter position and show it faintly in the next row. Stars: 3 for solving within the par number of guesses, 2 for one more, 1 for any win, minus one star if a hint was used. A level unlocks when the previous one has a star.
- Statistics: games played, win rate, win streak, best streak and a guess-distribution chart highlighting the current result. A Copy result button that copies a grid of coloured squares (orange and blue in high contrast mode). Save progress, stats, the streak and settings to localStorage inside try/catch.
- A high contrast colour option, Web Audio synth sounds with a mute button, confetti on a win, a result screen with the answer and stars, and a busy flag plus run id so typing and old timers are safe during the reveal.
- Scale the whole game to fit the available area (shrink with transform down to 40 percent) and stack the layout on narrow screens.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.