<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Vocabulary Spelling Game + Prize Wheel</title>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background: linear-gradient(to right, #11998e, #38ef7d);
color: white;
padding: 40px;
text-align: center;
margin: 0;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
}
h1 {
font-size: 3em;
margin-bottom: 20px;
}
#gameContainer {
background: rgba(0, 0, 0, 0.3);
padding: 30px;
border-radius: 15px;
display: inline-block;
max-width: 500px;
width: 90%;
}
input[type="text"] {
padding: 12px;
font-size: 1.2em;
border-radius: 8px;
border: none;
width: 80%;
margin-bottom: 15px;
}
button {
padding: 10px 20px;
font-size: 1em;
border: none;
border-radius: 8px;
background: #00c9ff;
color: white;
cursor: pointer;
margin: 5px;
transition: transform 0.2s;
}
button:hover {
background: #0077cc;
transform: scale(1.05);
}
#message {
margin-top: 10px;
font-size: 1.2em;
min-height: 30px;
}
#lives, #score {
font-weight: bold;
}
#wheel {
margin-top: 20px;
font-size: 1.1em;
background: #ffffff22;
padding: 10px;
border-radius: 10px;
display: none;
}
</style>
</head>
<body>
<h1>🧠 Guessero</h1>
<div id="gameContainer">
<p><strong>Lives:</strong> <span id="lives">6</span> | <strong>Score:</strong> <span id="score">0</span></p>
<p>Click <strong>Play Word</strong> to hear the word. Then type it!</p>
<button onclick="playWord()">🔊 Play Word</button><br />
<input type="text" id="answerInput" placeholder="Type the word here" autocomplete="off" />
<button onclick="checkAnswer()">Submit</button>
<p id="message"></p>
<div id="wheel"></div>
</div>
<script>
const words = [
"acquiesce", "benevolent", "camaraderie", "deceitful", "eloquence",
"facetious", "gregarious", "harbinger", "idiosyncrasy", "juxtaposition",
"kaleidoscope", "loquacious", "magnanimous", "nonchalant", "obfuscate",
"perseverance", "quintessential", "resilience", "serendipity", "tenacious",
"ubiquitous", "vociferous", "whimsical", "xenophobia", "zealous"
];
let currentWord = "";
let score = 0;
let lives = 6;
function speak(text) {
const msg = new SpeechSynthesisUtterance(text);
msg.rate = 0.8;
msg.pitch = 1;
window.speechSynthesis.speak(msg);
}
function speakLetters(word) {
for (let i = 0; i < word.length; i++) {
const msg = new SpeechSynthesisUtterance(word[i].toUpperCase());
msg.rate = 0.8;
msg.pitch = 1;
window.speechSynthesis.speak(msg);
}
}
function getRandomWord() {
return words[Math.floor(Math.random() * words.length)];
}
function playWord() {
if (lives === 0) return;
if (!currentWord) {
currentWord = getRandomWord();
}
speak(currentWord);
document.getElementById("message").textContent = "";
document.getElementById("wheel").style.display = "none"; // 👈 Hide prize display
}
function checkAnswer() {
const input = document.getElementById("answerInput");
const guess = input.value.trim().toLowerCase();
if (!currentWord) {
document.getElementById("message").textContent = "❗ Click 'Play Word' first.";
return;
}
if (guess === currentWord) {
score++;
document.getElementById("message").textContent = "✅ Correct! Spinning prize wheel...";
currentWord = ""; // reset word
updateStatus();
setTimeout(spinWheel, 1000); // delay to show spin
} else {
lives--;
document.getElementById("message").textContent = `❌ Incorrect. Try again or replay the word.`;
if (lives === 0) {
endGame();
}
updateStatus();
}
input.value = "";
}
function updateStatus() {
document.getElementById("lives").textContent = lives;
document.getElementById("score").textContent = score;
}
function endGame() {
const message = document.getElementById("message");
message.innerHTML = `💀 Game Over! The correct word was: <strong>${currentWord.toUpperCase()}</strong><br />🏆 Final Score: <strong>${score} points</strong>`;
speakLetters(currentWord);
document.getElementById("answerInput").disabled = true;
}
function spinWheel() {
const wheel = document.getElementById("wheel");
const prizes = [
{ text: "🎁 Extra Life!", action: () => lives++ },
{ text: "🎁 +2 Points!", action: () => score += 2 },
{ text: "🎁 +5 Points!", action: () => score += 5 },
{ text: "❌ No Prize", action: () => {} }
];
const prize = prizes[Math.floor(Math.random() * prizes.length)];
prize.action();
wheel.textContent = "🎉 " + prize.text;
wheel.style.display = "block";
updateStatus();
}
</script>
</body>
</html>
Write, Run & Share HTML code online using OneCompiler's HTML online Code editor for free. It's one of the robust, feature-rich online Code editor for HTML language, running on the latest version HTML5. Getting started with the OneCompiler's HTML compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as HTML. You can also specify the stylesheet information in styles.css tab and scripts information in scripts.js tab and start coding.
HTML(Hyper Text Markup language) is the standard markup language for Web pages, was created by Berners-Lee in the year 1991. Almost every web page over internet might be using HTML.
<!DOCTYPE html><html> and ends with </html><h1> to <h6> where <h1> is the highest important heading and <h6> is the least important sub-heading.<p>..</p> tag.<a> tag.
<a href="https://onecompiler.com/html">HTML online compiler</a>
<img> tag, where src attribute consists of image name.<button>..</button> tag<ul> for unordered/bullet list and <ol> for ordered/number list, and the list items are defined in <li>.<a href="https://onecompiler.com/html">HTML online compiler</a>
CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.
Below is a sample style sheet which displays heading in green and in Candara font with padding space of 25px.
body{
padding: 25px;
}
.title {
color: #228B22;
font-family: Candara;
}
<table> tag.<tr> tag<th> tag<td> tag<caption> tag<script> is the tag used to write scripts in HTML<script src="script.js"></script>