๐Ÿ’ฅ Anagram with HTML, CSS & JavaScript ๐ŸŽฎ

Hamna KaleemHamna Kaleem
3 min read

Do you love word games? ๐Ÿง  Want to brush up on your frontend coding while creating something fun? I built a simple yet addictive Anagram Game using plain HTML, CSS, and JavaScript โ€” no frameworks, no libraries, just vanilla goodness!

Letโ€™s walk through the project and inspire you to make your own or improve this one.


๐Ÿงฉ Whatโ€™s an Anagram?

An anagram is a word formed by rearranging the letters of another word. For example, "apple" can be turned into "papel". This game shuffles a word and asks the user to guess the original word in 3 tries!


๐ŸŽฎ How the Game Works

  • A random word is selected from a preset list (with fun hints! ๐ŸŽ‰)

  • Its letters are shuffled and shown to the player.

  • The player types their guess and hits Enter.

  • They get 3 tries, and if they're wrong, a helpful hint appears!

  • You can reshuffle the word if you get stuck.

  • Stop and restart options are available for more control.


๐ŸŒˆ Features

  • ๐ŸŽจ Stylish UI with pastel tones and emoji hints

  • ๐ŸŽฏ Real-time input with Enter key support

  • โ™ป๏ธ Automatic word reshuffle

  • ๐Ÿง  Score tracking

  • ๐Ÿ›‘ Pause and restart functionality


๐Ÿง  Technologies Used

  • HTML for structure

  • CSS for the styling including button colors and font choices like Comic Sans for fun vibes

  • JavaScript for game logic and interactivity


๐Ÿงช Try It in Colab or Jupyter (IPython)

You can embed this in a Jupyter Notebook using:

from IPython.core.display import display, HTML

html_code = """ 
<!-- (Paste your full HTML code here) -->
"""

display(HTML(html_code))

Itโ€™s a great way to combine Python environments with frontend practice!


๐Ÿ”ง Code Highlights

Shuffle logic:

function shuffle(str) {
  return str.split('').sort(() => Math.random() - 0.5).join('');
}

Guess check and feedback:

function checkGuess() {
  if (!gameActive) return;
  const guess = document.getElementById("guess").value.toLowerCase().trim();
  if (guess === current.word) {
    // success
  } else {
    // show hint or game over
  }
}

Keyboard integration:

document.getElementById("guess").addEventListener("keyup", function (event) {
  if (event.key === "Enter") {
    checkGuess();
  }
});

๐ŸŽ Bonus Ideas for Expansion

Want to make it more challenging or fun?

  • ๐Ÿ”Š Add sound effects or voice-based hints!

  • ๐Ÿ‘ฅ Multiplayer support

  • ๐Ÿ”  Categorize by difficulty or topic


๐ŸŽ‰ Final Thoughts

This was just a fun little side project to keep my creativity flowing and test frontend fundamentals. Whether you're a beginner or an expert, small games like these can sharpen your skills and make coding joyful again.

Feel free to fork it, remix it, and share your own versions! ๐Ÿš€


๐Ÿ’ฌ Whatโ€™s your favorite word game? Drop it in the comments! Or even better โ€” challenge me with an anagram !!!

0
Subscribe to my newsletter

Read articles from Hamna Kaleem directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Hamna Kaleem
Hamna Kaleem