HTML Code for Quiz

 HTML Code for Quiz


quiz,HTML quiz,web development quiz,HTML basics,form,form submission,radio buttons,input fields,button,front-end development,user interaction,web design,server-side processing,scoring logic.,


Below is a basic example of an HTML quiz form. Note that this form is for demonstration purposes only and lacks server-side validation and logic for scoring. For a real-world application, you would need to implement server-side processing to handle user input and calculate scores.


HTML

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Quiz</title>

    <style>

        body {

            font-family: Arial, sans-serif;

            margin: 0;

            padding: 0;

            display: flex;

            justify-content: center;

            align-items: center;

            height: 100vh;

        }


        form {

            max-width: 600px;

            width: 100%;

            background-color: #fff;

            padding: 20px;

            border-radius: 8px;

            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);

        }


        h2 {

            text-align: center;

        }


        label {

            display: block;

            margin-bottom: 8px;

        }


        input {

            margin-bottom: 16px;

        }


        button {

            background-color: #3498db;

            color: #fff;

            padding: 10px 15px;

            border: none;

            border-radius: 4px;

            cursor: pointer;

        }


        button:hover {

            background-color: #2980b9;

        }

    </style>

</head>

<body>

    <form action="#" method="post">

        <h2>Quiz: HTML Basics</h2>


        <label for="q1">1. What does HTML stand for?</label>

        <input type="radio" name="q1" value="a"> a) Hyper Text Markup Language<br>

        <input type="radio" name="q1" value="b"> b) High-level Text Markup Language<br>

        <input type="radio" name="q1" value="c"> c) Hyper Transfer Markup Language<br>


        <label for="q2">2. What is the correct HTML element for the largest heading?</label>

        <input type="radio" name="q2" value="a"> a) &lt;h1&gt;<br>

        <input type="radio" name="q2" value="b"> b) &lt;heading&gt;<br>

        <input type="radio" name="q2" value="c"> c) &lt;h6&gt;<br>


        <label for="q3">3. Which HTML element is used to define an unordered list?</label>

        <input type="radio" name="q3" value="a"> a) &lt;ul&gt;<br>

        <input type="radio" name="q3" value="b"> b) &lt;ol&gt;<br>

        <input type="radio" name="q3" value="c"> c) &lt;li&gt;<br>


        <button type="submit">Submit Quiz</button>

    </form>

</body>

</html>


Remember to replace the `action` attribute in the `<form>` tag with the appropriate URL for processing form submissions on your server. Additionally, for a real-world quiz, you'd need to implement server-side logic to score the quiz based on user responses.

Post a Comment

Previous Post Next Post