<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>True or False ISU Quiz</title> <style> body { font-family: Arial, sans-serif; display: flex; flex-direction: column; align-items: center; background-color: #f7f7f7; color: #333; margin: 0; } h1 { margin-top: 75px; font-size: 2.2em; color: #000; text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2); } .game-container { width: 90%; max-width: 600px; text-align: center; } .q-card { background-color: #ffffff; padding: 25px; margin: 15px; border-radius: 15px; border: 3px solid #45a049; box-shadow: 5px 5px 20px rgba(0, 0, 0, 0.2); transition: all 0.3s ease; } .q-card:hover { transform: scale(1.05); box-shadow: 7px 7px 25px rgba(0, 0, 0, 0.3); } .question { font-size: 1.3em; margin: 20px 0; } .buttons { display: flex; justify-content: space-around; margin-top: 20px; } .btn { background-color: #45a049; border: none; border-radius: 8px; padding: 12px 25px; cursor: pointer; font-size: 1em; color: #333; transition: background-color 0.3s ease; } .btn:hover { background-color: #f7f7f7; } .explanation-card { background-color: #d6fbe4; border-radius: 15px; padding: 20px; margin-top: 20px; display: none; box-shadow: 3px 3px 15px rgba(0, 0, 0, 0.2); } </style> </head> <body> <h1>True or False ISU Quiz 😊</h1> <div class="game-container"> <div class="q-card" id="question-card"> <div id="question" class="question"></div> <div class="buttons"> <button class="btn" onclick="checkAnswer(true)">True</button> <button class="btn" onclick="checkAnswer(false)">False</button> </div> </div> <div class="explanation-card" id="explanation-card"> <p id="explanation-text"></p> <button class="btn" onclick="nextQuestion()">Next Question</button> </div> <script> const questions = [ { question: "When we double the radius of a cylinder, the volume quadruples.", answer: true, explanation: "It's actually true!" }, { question: "When the height of a cylinder doubles, the volume quadruples.", answer: false, explanation: "It's false! When we double the height, the volume will DOUBLE!" }, { question: "The formula for the surface area of a rectangular prism is: SA= 2(wl+hl+hw).", answer: true, explanation: "It's true!" }, { question: "A pyramid with the same base area and height as a rectangular prism will be 1/3 its volume.", answer: true, explanation: "It is true!" }, { question: "Doubling the radius of a cylinder has more impact than doubling the height.", answer: true, explanation: "It is true!" }, { question: "The formula for volume for a sphere is: 4/3 π r³.", answer: true, explanation: "It is actually true!" }, { question: "A cube is a two-dimensional shape.", answer: false, explanation: "Nope! It is a 3D shape." }, { question: "The formula for the surface area of a sphere is 4πr", answer: false, explanation: "Nope! Don't forget about the squared at the end..." }, { question: "The formula for the surface area of a sphere is 4πr^2", answer: true, explanation: "Hey! Were you paying attention before? This is true!" }, { question: "Ms. Shrestha is the coolest math teacher.", answer: true, explanation: "It is true!" }, ]; let currentQuestionIndex = 0; function loadQuestion() { const currentQuestion = questions[currentQuestionIndex]; document.getElementById("question").textContent = currentQuestion.question; document.getElementById("explanation-card").style.display = "none"; document.getElementById("question-card").style.display = "block"; } function checkAnswer(isTrue) { const currentQuestion = questions[currentQuestionIndex]; if (isTrue === currentQuestion.answer) { alert("Correct!"); nextQuestion(); } else { document.getElementById("explanation-text").textContent = currentQuestion.explanation; document.getElementById("question-card").style.display = "none"; document.getElementById("explanation-card").style.display = "block"; } } function nextQuestion() { currentQuestionIndex++; if (currentQuestionIndex < questions.length) { loadQuestion(); } else { document.getElementById("question-card").innerHTML = "<h2>You've completed the quiz! 🎉</h2>"; document.getElementById("explanation-card").style.display = "none"; } } window.onload = loadQuestion; </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>