Frontend Web Technologies (HTML, CSS, JavaScript & DOM): past questions

16 questions · 49 marks · 9 papers. Try each one before checking.

Solve them and check answers →Read the notes first

24 Mar 2024

Question 16 MSQ · 4.5 marks

Consider the following HTML document and select the correct option(s).

<!DOCTYPE html>
<html>
<head>
    <title>Form Validation</title>
    <script>
        function validateForm() {
            var username = document.forms["myForm"]["username"].value;
            var password = document.forms["myForm"]["password"].value;
            if (username == "") {
                alert("Username must be filled out");
                return false;
            }
            if (password.length < 8) {
                alert("Password must be at least 8 characters long");
                return false;
            }
        }
    </script>
</head>
<body>
    <form name="myForm" onsubmit="validateForm()">
        <label for="username">Username:</label>
        <input type="text" name="username">
        <label for="password">Password:</label>
        <input type="password" name="password" required>
        <input type="submit" value="Submit">
    </form>
</body>
</html>

  1. The JavaScript function, 'validateForm' performs the backend processing of form data.
  2. The JavaScript function, 'validateForm' carries out the client side validation of form data.
  3. If the password field is left empty, on submission, the user will get a prompt "Please fill out this field." near the password field.
  4. If the password field is left empty, on submission, the user will get a prompt "Password must be at least 8 characters long" from the browser.

04 Aug 2024

Question 19 MSQ · 4.5 marks

Consider the following HTML Document and select the correct statement(s) from the following if a user types the password “mad1password” in the password field letter by letter.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Login Form</title>
    <style>
        input[type="password"]:valid{
            background-color: green;
        }
        input[type="password"]:invalid{
            background-color: red;
        }
    </style>
</head>
<body>
    <div class="login-form">
        <h2>Login</h2>
        <form>
            E-mail: <input type="email" id="email" name="email" required>
            Password: <input type="password" id="password" name="password"
                             required minlength="5" maxlength="8">
            <input type="submit" value="Login">
        </form>
    </div>
</body>
</html>

  1. The HTML form is integrated with backend validation.
  2. The HTML form is integrated with Frontend HTML5 validation.
  3. The background colour of the password field remains red for the first 4 letters,then turns green for the next 4 letters, and then again turns red for the remaining letters.
  4. The background colour of the password field remains red for the first 4 letters,then turns green for the next 4 letters, and then remains green for the remaining allowable letters.

01 Dec 2024

Question 15 MSQ · 2 marks

Which of the following statements are correct?

  1. HTML defines the styling, while CSS defines the content
  2. HTML defines the content, while CSS defines the styling
  3. JavaScript is always the core part of an application's frontend
  4. JavaScript provides additional functionality at the frontend

16 Mar 2025

Question 3 MCQ · 2 marks

Which of the following best describes the primary advantage of asynchronous updates in web applications?

  1. It ensures that all elements of a web page are loaded at the same time.
  2. It improves performance by allowing parts of a webpage to update withoutrequiring a full reload.
  3. It forces the client to wait until the server responds before interacting with thepage.
  4. It requires a high-speed internet connection to function correctly.

03 Aug 2025

Question 5 MCQ · 2 marks

What is the right syntax to use an external JavaScript file(.js) into the current html file?

  1. <script src="jsfile.js"></script>
  2. <script href="jsfile.js"></script>
  3. <import src="jsfile.js"></import>
  4. <import link="jsfile.js"></import>

Question 10 MCQ · 4.5 marks

Consider the following HTML code. Filename: main.html

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Greetings</title>
</head>
<body>
    <button onclick="alert('Hello, welcome')">Greet1!</button><br>
    <button onclick="console.log('Hello, welcome')">Greet2!</button><br>
    <button onclick="document.write('Hello, welcome')">Greet3!</button><br>
    <button onclick="console.error('Hello, welcome')">Greet4!</button>
</body>
</html>

Rendered HTML output below: [Image Description: Four stacked HTML buttons labeled "Greet1!", "Greet2!", "Greet3!", and "Greet4!".]

Which of the above “Greet” buttons will print greetings on the dialogue box?

  1. Greet4
  2. Greet3
  3. Greet2
  4. Greet1

14 Aug 2026

Question 6 MCQ · 3 marks

A recipe webpage needs to display two distinct sections:

  1. A list of ingredients where the order does not matter.
  1. A sequence of cooking steps that must be followed in order.

Which combination of HTML list container tags is most appropriate for these sections?

  1. Ingredients: <ol> | Cooking Steps: <ol>
  2. Ingredients: <ul> | Cooking Steps: <ul>
  3. Ingredients: <dl> | Cooking Steps: <ul>
  4. Ingredients: <ul> | Cooking Steps: <ol>

Question 15 MSQ · 2 marks

Which of the following statements is/are true about Document Object Model (DOM)?

  1. It is the programming interface for web documents.
  2. It is the abstract model of the document.
  3. Its structure is rigid and cannot be changed once created.
  4. It can only be manipulated with the help of JavaScript.

Question 11 MCQ · 2 marks

In the context of asynchronous updates, which of the following statements is correct?

  1. It updates a web page without reloading the whole page
  2. It leads to better user experience as it involves quick response on the main page with minimal data to refresh
  3. Both It updates a web page without reloading the whole page and It leads to better user experience as it involves quick response on the main page with minimal data to refresh are correct
  4. None of these

July 2022

Question 14 MCQ · 4.5 marks

Consider the HTML document given below:

<!DOCTYPE html>
<html>
<head>
<style>
    [id~=out] {
        border: 10px solid red;
    }
    [class~=out]{
        border: 5px solid yellow;
    }
</style>
</head>
<body>
    <h2>Hello World!</h2>
    <h1 id="out">Hey!</h1>
    <p id="out-text">My name is Fred.</p>
    <p class="outcontent">I am learning to develop applications.</p>
    <p id="out"> Are you also willing to learn?</p>
    <p class="out">Welcome to the world of Application development!</p>
    <h3>Have a nice day!!</h3>
</body>
</html>

Which of the following statements is true for the above HTML document when rendered by the browser?

  1. The headings, i.e., 'Hello World!' and 'Hey!', both will have red border color.
  2. The paragraph with class='out', will get a yellow color border.
  3. The paragraph with id='out' will get a yellow color border.
  4. The two paragraphs with contents, 'My name is Fred.' and 'I am learning todevelop applications.', will both get a red color border and yellow color border.

Question 9 MCQ · 3 marks

Consider the following HTML file with embedded JavaScript. Filename: index.html

<!DOCTYPE html>
<html>
<body>
    <h2>Creating a Json Object </h2>
    <p id="jsonobj"></p>
    <script>
        const txt = '{"name":"icecream","type":"cup", "flavor":"vanilla"}'
        const obj = JSON.parse(txt);
        document.getElementById("jsonobj").innerHTML = obj.name + ", " + obj.flavor + ", " + obj.type;
    </script>
</body>
</html>

How will the browser render the above HTML file?

  1. Creating a Json Object undefined, undefined, undefined
  2. Creating a Json Object vanilla, icecream, cup
  3. Creating a Json Object cup, vanilla, icecream
  4. Creating a Json Object icecream, vanilla, cup

Aug 2023

Question 7 MCQ · 3 marks

Consider the following HTML Document file given below. index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Document</title>
    <style>
        input:invalid {
            background: red;
        }
        input:valid {
            background: green;
        }
    </style>
</head>
<body>
    <form>
        <label for="uname">Enter a valid e-mail:</label>
        <input type="text" name="uname" minlength="8">
    </form>
</body>
</html>

Suppose the index.html is rendered on the browser. What will be the background color of the input box when the user enters the name “madcourse.mail.com"?

  1. red
  2. white
  3. green
  4. insufficient information

Question 15 MSQ · 3 marks

Which of the following is/are valid JSON format.

  1. { "Age": 27, "firstName": "John", "lastName": "Pollard", "married": false, "phone_numbers": ["212-555-1234", "212-666-5678"] }
  2. { "RollNumber": 11, "firstName": "Nick", "lastName": "Paul", "phone_numbers": [2125551234, "2124441234"] }
  3. { "firstName": "Will", "lastName": "Smith", "address": [ "addressLine": "Lake Union Hill Way", "city": "Atlanta", "zipCode": 50005 ] }
  4. { "firstName": "Hannah", "lastName": "Smith", "cities": ["Dallas", "San Antonio", "Irving"], "phone_numbers": ["212-555-1234", "212-666-5678"] }

06 Apr 2026

Question 7 MCQ · 3 marks

Consider the following HTML/CSS code.

<!DOCTYPE html>
<html>
<head>
    <style>
        p { color: blue; }
        .text { color: green; }
        #para { color: red; }
    </style>
</head>
<body>
    <p id="para" class="text" style="color: black;">
        IITM BS Degree Program
    </p>
</body>
</html>

What will be the output when the above HTML file is rendered?

[Image Description: The four options show the text "IITM BS Degree Program" rendered in four different font colors corresponding to the CSS rules: blue, green, red, and black.]

  1. IITM BS Degree Program (in blue color)
  2. IITM BS Degree Program (in green color)
  3. IITM BS Degree Program (in red color)
  4. IITM BS Degree Program (in black color)

Question 12 MCQ · 4 marks

Consider the following HTML code.

<!DOCTYPE html>
<html>
<body>
    <ol id="lst">
        <li>App Dev-1</li>
    </ol>
</body>
<script>
    let lst_items=document.getElementsByTagName("li");
    document.getElementById("lst").innerHTML += "<li>App Dev-2</li><li>App dev projects</li>";
    console.log(lst_items.length);
</script>
</html>

What will be the output in the console window when the above HTML doc is rendered on the browser ?

  1. 1
  2. 2
  3. 3
  4. 4

Question 2 MCQ · 2 marks

Which of the following enables asynchronous communication between client and server without loading the entire web page?

  1. CGI
  2. FTP
  3. SMTP
  4. AJAX

Check your answers →

Weeks covering this topic

Other MAD 1 topics