Quiz of Trains - HTML
Quiz of Trains - HTML
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>History of Trains Quiz</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #f9f9f9;
color: #333;
}
h1, h2 {
text-align: center;
}
.question {
margin: 20px 0;
}
.options label {
display: block;
padding: 8px;
background: #e7e7e7;
margin-bottom: 5px;
cursor: pointer;
border-radius: 4px;
}
.options input[type="radio"] {
display: none;
}
button {
display: block;
width: 100%;
padding: 10px;
margin-top: 20px;
font-size: 16px;
background-color: #333;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #555;
}
.result {
margin-top: 20px;
padding: 15px;
text-align: center;
font-weight: bold;
}
.correct {
background-color: #d4edda;
color: #155724;
}
.incorrect {
background-color: #f8d7da;
color: #721c24;
}
</style>
</head>
<body>
<div id="quiz">
<div class="question">
<h2>1. When was the world’s first full-scale working railway steam
locomotive built?</h2>
<div class="options">
<label><input type="radio" name="q1" value="A"> A) 1784</label>
<label><input type="radio" name="q1" value="B"> B) 1804</label>
<label><input type="radio" name="q1" value="C"> C) 1814</label>
<label><input type="radio" name="q1" value="D"> D) 1829</label>
</div>
</div>
<div class="question">
<h2>2. Who built the first successful steam locomotive?</h2>
<div class="options">
<label><input type="radio" name="q2" value="A"> A) George
Stephenson</label>
<label><input type="radio" name="q2" value="B"> B) Richard
Trevithick</label>
<label><input type="radio" name="q2" value="C"> C) James
Watt</label>
<label><input type="radio" name="q2" value="D"> D) Robert
Stephenson</label>
</div>
</div>
<div class="question">
<h2>3. What was the name of the first railway to carry both passengers
and freight with steam locomotives in 1825?</h2>
<div class="options">
<label><input type="radio" name="q3" value="A"> A) Liverpool and
Manchester Railway</label>
<label><input type="radio" name="q3" value="B"> B) Stockton and
Darlington Railway</label>
<label><input type="radio" name="q3" value="C"> C) Great Western
Railway</label>
<label><input type="radio" name="q3" value="D"> D) London and North
Western Railway</label>
</div>
</div>
<!-- Additional questions go here, using the same structure as above -->
<script>
function checkAnswers() {
const answers = {
q1: 'B',
q2: 'B',
q3: 'B'
// Add additional questions here
};
let score = 0;
let totalQuestions = Object.keys(answers).length;
</body>
</html>