HTML MCQs
Q.1 Spot the error in: <p>HTML is <em>fun</u> to learn</p>
A. <em> tag not closed
B. <u> tag not closed
C. Incorrect tag pairing
D. No error
Q.2 Identify the mistake: <html> <body> <p>HTML is <i>very</i><b> interesting.</p> </body> </html>
A. <i> tag not closed
B. <b> tag not closed
C. <p> tag not closed
D. No mistake
Q.3 Find the error in this HTML snippet: <p>Welcome to <b>our website</p></b>
A. Missing end tag for <b>
B. Incorrect nesting of <b> and <p>
C. Missing start tag for <b>
D. No error
Q.4 Which tag is used to create a line break in an HTML document?
A. <break>
B. <lb>
C. <br>
D. <newline>
Q.5 What is the result of this HTML code: <p>This is <b>important</b> text.</p>?
A. This is important text
B. This is <b>important</b> text
C. This is IMPORTANT text
D. This is important Text
Q.6 Which HTML element is used to define a part of text in an alternate voice or mood?
A. <data>
B. <time>
C. <mark>
D. <small>
Q.7 Which tag is used to define marked or highlighted text in HTML?
A. <mark>
B. <highlight>
C. <em>
D. <strong>
Q.8 What does the <abbr> tag represent in HTML?
A. Abbreviation or acronym
B. Address block
C. Article body
D. Audio broadcast
Q.9 Which HTML tag is used to underline text?
A. <u>
B. <underline>
C. <ul>
D. <line>
Q.10 Which tag is used to display text in a monospaced (typewriter−style) font in HTML?
A. <monospace>
B. <code>
C. <typewriter>
D. <pre>
Q.11 How is a subscript text displayed using HTML tags?
A. <sub>
B. <sup>
C. <small>
D. <low>
Q.12 Which HTML tag is used to represent a thematic break in the content?
A. <break>
B. <line>
C. <hr>
D. <divider>
Q.13 What is the purpose of the <em> tag in HTML?
A. To underline text
B. To emphasize text
C. To change text color
D. To create a paragraph
Q.14 Which tag is used to make text bold in HTML?
A. <em>
B. <strong>
C. <mark>
D. <bold>
Q.15 Spot the error in this HTML document structure:<html><head><title>Document</title></head><body><h1>Heading</p><p>Paragraph</h1></body></html>
A. Incorrect nesting of tags
B. Missing <title> tag
C. Extra <html> tag
D. Wrong order of elements
Q.16 Identify the mistake in this HTML code: <html><head><title>My Page</title><body><p>Welcome to my page</p></body></head></html>
A. Misplaced <title> tag
B. Missing <body> tag
C. Incorrect closing order of tags
D. Extra <head> tag
Q.17 Which HTML element is used to define the footer of an HTML document?
A. <footer>
B. <bottom>
C. <end>
D. <foot>
Q.18 What will be displayed on the web page for this HTML code: <html><head><title>Page Title</title></head><body>Hello World</body></html>?
A. Page Title
B. Hello World
C. Both Page Title and Hello World
D. Nothing
Q.19 What is the primary purpose of the <body> tag in an HTML document?
A. Contains the document’s metadata
B. Defines the title of the document
C. Holds the content visible to the user
D. Specifies external resources
Q.20 Which of the following elements are considered ‘block−level’ elements in HTML?
A. <img> and <a>
B. <p> and <div>
C. <span> and <i>
D. <b> and <strong>
Q.21 In HTML, which tag is used to create a paragraph?
A. <p>
B. <par>
C. <text>
D. <div>
Q.22 What is the function of the <head> element in an HTML document?
A. Contains the document’s body content
B. Is displayed in the browser’s viewing area
C. Includes metadata, title, and scripts
D. Defines the footer of the page
Q.23 Which of the following tags are mandatory in an HTML document?
A. <body> and <title>
B. <head> and <body>
C. <header> and <footer>
D. <p> and <h1>
Q.24 Which tag is used to define the title of a document in HTML?
A. <body>
B. <title>
C. <head>
D. <br>
Q.25 What will be displayed in the browser for the following HTML code? <html><body><h1>Hello World</h1></body></html>
A. A blank page
B. Text “Hello World” in paragraph format
C. Text “Hello World” in heading format
D. An error message
Q.26 What is the significance of the DOCTYPE declaration in HTML?
A. It links HTML with CSS
B. It is required for creating HTML forms
C. It defines the HTML version being used
D. It enables JavaScript in HTML
Q.27 HTML web pages are read and rendered by which of the following?
A. HTML 4.01
B. XHTML
C. HTML5
D. HTML 3.2
Q.28 HTML web pages are read and rendered by which of the following?
A. Compilers
B. Servers
C. Web browsers
D. Database systems
Q.29 Which of the following is a use of HTML?
A. Creating spreadsheets
B. Programming applications
C. Designing web pages
D. Editing videos
Q.30 What does HTML stand for?
A. Hyper Text Markup Language
B. Hyperlinks and Text Markup Language
C. Hyperlinks and Text Markup Language
D. Hyperlinking Text Marking Language
Q.31 Identify the error in this HTML form code: <form action=”/submit” method=”get”><input type=”text” name=”email”><input type=”submit”></form>
A. Missing method attribute in the form tag
B. Missing name attribute in the submit input
C. Incorrect action URL
D. No error
Q.32 What does this HTML code achieve: <table><tr><th rowspan=”2″>Name</th><th>Age</th></tr><tr><th>Gender</th></tr></table>?
A. Creates a table with 2 rows and 2 columns
B. Creates a table with 2 rows and 3 columns
C. Creates a table with 1 row and 3 columns
D. Creates a table with 3 rows and 1 column
Q. 33 What is the purpose of this HTML code: <label for=”fname”>First name:</label><input type=”text” id=”fname” name=”fname”>?
A. To create a labeled checkbox
B. To create a labeled text field
C. To create a submit button
D. To display a user’s name
Q. 34 How will this HTML code render?<input type=”email” name=”email”>
A. As a password field
B. As a text field
C. As an email field
D. As a number field
Q.35 What does this HTML code create? <form action=”/submit.php” method=”post”><input type=”text” name=”name”><input type=”submit” value=”Submit”></form>
A. A search bar
B. A subscription form
C. A user registration form
D. A feedback form
Q.36 What will be the output of this HTML code: <table><tr><td>Cell 1</td><td>Cell 2</td></tr></table>?
A. Two tables with one cell each
B. One table with two rows
C. One table with one row and two cells
D. One table with two columns
Q.37 Which attribute is used to specify that an input field must be filled out before submitting a form?
A. required
B. mandatory
C. important
D. need
Q.38 How do you associate a label with a specific form element?
A. By placing the element inside the label
B. By using the id attribute of the element and the for attribute of the label
C. By using the name attribute
D. By using the align attribute
Q.39 In HTML, which input type is used for creating a slider control?
A. text
B. range
C. slider
D. scroll
Q.40 What is the purpose of the <thead> element in an HTML table?
A. To set the table header
B. To add a title to the table
C. To define the table’s top row
D. To style the table
Q.41 Which HTML tag is used for grouping together related elements and labels within a form?
A. <group>
B. <fieldset>
C. <form−set>
D. <form−group>
Q. 42 In HTML forms, which attribute specifies the URL where form data is sent when submitted?
A. action
B. method
C. target
D. enctype
Q.43 Which HTML tag is used to create a table?
A. <table>
B. <tab>
C. <grid>
D. <data−table>
Q.44 Spot the error in this code:<a href=”/page2.html”><img src=”button.jpg” alt=”Button”></a>
A. The <img> tag is incorrectly placed inside <a>
B. The href attribute is missing the URL
C. The alt attribute should not be used with <img>
D. No error
Q.45 What is wrong with this HTML line: <img src=”image.png” alt=”Image” width=”100″ height=”100″/>?
A. The src attribute is incorrect
B. The alt attribute should not be used
C. The self−closing tag is unnecessary
D. No error
Q.46 Find the mistake:<a href=”www.example.com”>Example</a>
A. Missing ‘http://’ or ‘https://’ in the href attribute
B. Incorrect tag used
C. No text in the link
D. No mistake
Q.47 Identify the issue in this HTML code: <ul><li>Item 1<li>Item 2</ul>
A. Missing <ul> closing tag
B. Missing <li> closing tags
C. Incorrect nesting of <li> tags
D. No error
Q.48 Spot the error: <img src=”photo.jpeg” alt=Photo of a cat>
A. Missing quotes around the alt attribute value
B. Incorrect file extension
C. Missing src attribute
D. No error
Q.49 How will this HTML snippet render? <a href=”#section2″>Jump to Section 2</a>
A. As a button linking to another website
B. As a hyperlink jumping to a section on the same page
C. As a non−clickable text
D. As an image link
Q.50 What will this HTML code display? <ol><li>First</li><li>Second</li><li>Third</li></ol>
A. A bulleted list of First, Second, Third
B. A numbered list of First, Second, Third
C. A list of links
D. A list with checkboxes
Q.51 What is the result of the following HTML code?<img src=”image.jpg” alt=”MyImage”>
A. A text “MyImage”
B. An image with alternate text “MyImage”
C. An image named “image.jpg”
D. A broken image link with no alternate text
Q.52 What does this HTML code produce?<a href=”https://www.example.com”>Visit Example</a>
A. A button to visit Example.com
B. A text “Visit Example” with a hyperlink
C. An image linking to Example.com
D. An email link to Example.com
Q.53 What will be the output of the following HTML code? <ul><li>Coffee</li><li>Tea</li><li>Milk</li></ul>
A. A numbered list of Coffee, Tea, Milk
B. A bulleted list of Coffee, Tea, Milk
C. A paragraph containing Coffee, Tea, Milk
D. A dropdown list with Coffee, Tea, Milk
Q.54 How do you create a numbered list in HTML?
A. Using the <ul> tag
B. Using the <ol> tag
C. Using the <li> tag
D. Using the <nl> tag
Q.55 Which HTML tag is used to create a description list, often used for glossaries or to present metadata?
A. <dl>
B. <ul>
C. <ol>
D. <list>
Q.56 What is the purpose of the alt attribute in an image tag?
A. To provide a text description of the image
B. To change the image size
C. To link the image to another page
D. To specify additional images
Q.57 Which attribute in the <img> tag specifies the URL of the image?
A. src
B. href
C. link
D. source
Q.58 In HTML, which tag is used for creating a hyperlink?
A. <link>
B. <a>
C. <href>
D. <hyperlink>
Q.59 Which HTML tag is used to create an unordered list?
A. <ul>
B. <ol>
C. <li>
D. <dl>
Q.60 What is the problem with this HTML line:<p>This text is <strong>very</strong> <em>important</em?</p>
A. Missing end tag for <em>
B. Incorrect use of <strong>
C. <p> tag not closed
D. No error
Q.61 Spot the error in this HTML5 audio tag: <audio controls><source src=”audio.mp3″ type=”audio/mpeg”><source src=”audio.ogg” type=”audio/ogg”></audio>
A. The controls attribute should be inside the <source> tag
B. Missing src attribute in the <audio> tag
C. Incorrect MIME type for the .ogg file
D. No error
Q.62 Identify the mistake in this HTML5 video tag:<video src=”movie.mp4″ controls autoplay></video>
A. Incorrect file path in src
B. Missing width and height attributes
C. Autoplay should not be used with controls
D. No mistake
Q.63 What does this HTML5 code achieve?<video width=”320″ height=”240″ controls><source src=”movie.mp4″ type=”video/mp4″><source src=”movie.ogg” type=”video/ogg”>Your browser does not support the video tag.</video>
A. Displays two different videos side by side
B. Chooses the best video format automatically
C. Plays two videos in sequence
D. Shows an error message
Q.64 How will this HTML5 code be displayed?<audio src=”sound.mp3″ controls></audio>
A. A static image with a sound icon
B. A video player playing “sound.mp3”
C. An audio player for “sound.mp3” with controls
D. Text with a link to “sound.mp3”
Q.65 What will this HTML5 code display? <video src=”movie.mp4″ width=”320″ height=”240″></video>
A. A video player with a video from “movie.mp4”
B. An audio player playing “movie.mp4”
C. A broken video link
D. A static image from “movie.mp4”
Q.66 Which format is universally supported by the HTML5 <audio> tag across all major browsers?
A. MP3
B. WAV
C. OGG
D. AAC
Q.67 What does the loop attribute do in an HTML5 <video> element?
A. Repeats the video a specified number of times
B. Causes the video to play in reverse
C. Automatically plays the next video
D. Continuously loops the video
Q.68 In HTML5, which attribute is used to automatically play a video when the page is loaded?
A. autoplay
B. auto
C. play
D. load
Q.69 What is the purpose of the controls attribute in the HTML5 <audio> tag?
A. To set the audio file path
B. To autoplay the audio
C. To display play, pause, and volume controls
D. To loop the audio
Q.70 Which HTML5 tag is used to embed video files into a web page?
A. <media>
B. <video>
C. <movie>
D. <clip>
Q.71 Find the error in this code: <figure><img src=”image.jpg”><figcaption>Image description</figure>
A. Missing alt attribute in <img>
B. Incorrect placement of <figcaption>
C. Missing closing </figcaption> tag
D. No error
Q.72 What is wrong with this HTML5 code: <main><article>This is an article</article><aside>This is an aside</aside></main>?
A. <main> should not contain <article>
B. <aside> should not be inside <main>
C. Missing <h1> in <article>
D. No error
Q.73 Spot the mistake in this HTML5 snippet: <section><header><h1>Title</h1></header><p>Paragraph</section>
A. Missing closing </p> tag
B. Missing closing </header> tag
C. Incorrect order of tags
D. Incomplete <section> tag
Q.74 Identify the issue in this HTML5 code:<footer><nav><ul><li>Home</li></ul></nav></footer>
A. Incorrect placement of <nav> within <footer>
B. Missing <a> tags in <nav>
C. Inappropriate use of <ul>
D. No error
Q.75 What does this HTML5 code achieve? <section><h2>Heading</h2><p>Some text…</p></section>
A. Defines a specific section of a document
B. Creates a new webpage
C. Designs a new template
D. Generates a pop−up
Q.76 What will this HTML5 code represent? <article><h2>Article Title</h2><p>Content here…</p></article>
A. A comment section
B. A main navigation bar
C. An independent, self−contained composition
D. A header section
Q.77 How does this HTML5 snippet function?<aside><p>This is a sidebar.</p></aside>
A. Creates a main content area
B. Creates a footer section
C. Creates a sidebar
D. Creates a header
Q.78 What does this HTML5 code create?<nav><ul><li><a href=”#home”>Home</a></li><li><a href=”#about”>About</a></li></ul></nav>
A. A list of images
B. A set of radio buttons
C. A navigation bar with links
D. A group of checkboxes
Q.79 How will this HTML5 code be displayed?<header><h1>Welcome to My Page</h1></header>
A. As a header with large bold text
B. As a paragraph
C. As a footer
D. As a navigation bar
Q.80 What is the significance of the <main> element in HTML5?
A. To define the main navigation links
B. To specify the main content of a document
C. To create the main header
D. To define the primary footer
Q.81 Which element is used in HTML5 to mark up a conversation, such as dialogue in a play or instant
messaging conversation?
A. <dialog>
B. <chat>
C. <conversation>
D. <talk>
Q.82 What is the purpose of the <figure> and <figcaption> elements in HTML5?
A. To create a photo gallery
B. To define self−contained content with a caption
C. To display a figure in a scientific paper
D. To create a navigation bar
Q.83 In HTML5, which element is best suited for content that is tangentially related to the main content, like a sidebar?
A. <aside>
B. <section>
C. <article>
D. <footer>
Q.84 Which HTML5 semantic element should be used to define a section of a page that could be syndicated
as a standalone unit?
A. <section>
B. <aside>
C. <article>
D. <header>
Q.85 What is the purpose of the <article> element in HTML5?
A. To mark up advertisements
B. To create a navigation bar
C. To define independent content that can be distributed
D. To define the header of a document
Q.86 Which HTML5 element is typically used for the main navigation section?
A. <section>
B. <footer>
C. <header>
D. <nav>
Q.87 What is the main purpose of using semantic elements in HTML5?
A. To enhance the look of the webpage
B. To make the code shorter
C. To improve search engine optimization and accessibility
D. To change the layout of the webpage
Q.88 Find the error in this table structure:<table><thead><tr><th>ID</th><th>Name</th></thead><tbody><tr><td>1</td><td>John</td></tr></tbody></table>
A. Missing <tr> tag in <thead>
B. Missing <tr> tag in <tbody>
C. Incomplete <thead> section
D. Incomplete <tbody> section
Q.89 What is wrong with this HTML form element: <input type=”text” required=”true” name=”username”>?
A. The type attribute is incorrect
B. The required attribute does not need a value
C. The name attribute is unnecessary
D. No error
Q.90 Spot the mistake in this HTML table code:<table><tr><td rowspan=”2″>Item 1</td><td>Price</td></tr><tr><td>Quantity</td></td></tr></table>
A. Incorrect rowspan attribute
B. Extra </td> tag
C. Missing <th> tags
D. No mistake
Q.91 Which CSS property is used to change the background color of an element?
A. color
B. bgcolor
C. background−color
D. background−image
Q.92 What does the ‘Cascading’ in Cascading Style Sheets (CSS) refer to?
A. The way styles cascade from parent elements to child elements
B. The cascading effect of animations and transitions
C. The way styles are loaded sequentially in a browser
D. The cascading order of style rules when conflicts arise
Q.93 How do you link an external CSS stylesheet to an HTML document?
A. With the <script> tag
B. With the <link> tag
C. With the <css> tag
D. With inline styles in the HTML elements
Q.94 What is the purpose of CSS in HTML?
A. To create the structure of web pages
B. To add interactivity to web pages
C. To define the style and layout of web pages
D. To increase the loading speed of web pages
Q.95 Spot the error in this HTML code from an accessibility perspective: <input type=”text” name=”name”
aria−label=”Name”>
A. The type attribute is incorrect
B. The name attribute should match the aria−label
C. There should be a visible label in addition to aria−label
D. The aria−label attribute is unnecessary
Q.96 Identify the accessibility issue in this HTML code: <img src=”photo.jpg”>
A. The image file is too large
B. The src attribute is incorrect
C. There is no alt attribute
D. The image format is not supported
Q.97 How does this HTML code improve accessibility? <button aria−label=”Close”>X</button>
A. By labeling the button for screen readers
B. By increasing the font size of the button text
C. By making the button more visually distinct
D. By adding a keyboard shortcut to the button
Q.98 What is the purpose of this HTML code in terms of accessibility? <a href=”https://www.example.com”
title=”Visit Example Website”>Example</a>
A. To provide a tooltip for the link
B. To make the link open in a new tab
C. To indicate that the link is external
D. To display a description when the link is focused or hovered
Q.99 What is the purpose of the aria−labelledby attribute in HTML?
A. To label elements for styling purposes
B. To specify a unique ID for an element
C. To reference the ID of another element that provides a label
D. To automatically generate labels for elements
Q.100 How does the use of semantic HTML elements like <header>, <footer>, <nav>, and <main> enhance accessibility?
A. By making the website load faster
B. By improving the website’s SEO
C. By making it easier for screen readers to navigate the content
D. By changing the visual appearance of the site
Q.101 What role does the lang attribute in the <html> tag play in web accessibility?
A. Specifies the language of the script used in the document
B. Determines the language for styling the document
C. Specifies the primary language of the document’s content
D. Controls the language of the browser interface
Q.102 What is the primary purpose of using alt text in HTML images?
A. To provide a text alternative for search engines
B. To increase image loading speed
C. To provide a text description for screen readers
D. To display text when an image link is broken
Q.103 Identify the mistake in this Drag and Drop code: HTML: <div id=”drag1″ draggable=”true”></div> JS: document.getElementById(“drag1”).addEventListener(“dragstart”, function(event) { event.dataTransfer.setData(“text”, event.target.id); });
A. The data type set in setData is incorrect
B. The draggable attribute is not set correctly
C. The event listener is attached to the wrong element
D. No mistake
Q.104 Spot the error in this HTML5 Canvas code:<canvas id=”canvas”></canvas> JS: var c = document.getElementById(‘canvas’); var ctx = c.getContext(‘2d’); ctx.fillReact(10, 10, 100, 100);
A. Incorrect method name fillReact
B. Incorrect context retrieval
C. Canvas element incorrectly referenced
D. No error
Q.105 How does this HTML5 code function for Drag and Drop? HTML: <div id=”drag1″ draggable=”true”></div> JS: document.getElementById(“drag1”).addEventListener(“dragstart”, function(event) { event.dataTransfer.setData(“text/plain”, event.target.id); });
A. It makes the div draggable and stores the div’s ID
B. It prevents the div from being dropped
C. It tracks the movement of the mouse
D. It changes the style of the div when dragged
Q.106 What is the purpose of this HTML5 Canvas code: <canvas id=”myCanvas”></canvas> in HTML and var canvas = document.getElementById(‘myCanvas’); var ctx = canvas.getContext(‘2d’); ctx.fillRect(20, 20, 150, 100); in JavaScript?
A. To create an interactive form
B. To display a static image
C. To draw a rectangle on the canvas
D. To create an animation
Q.107 What are the primary advantages of using HTML5’s Canvas API over traditional bitmap images?
A. Faster load times and smaller file sizes
B. Interactivity and programmability
C. Higher quality images and transparency support
D. Compatibility with older browsers
Q.108 How does the <canvas> element differ from <svg> in HTML5?
A. <canvas> requires a plugin, while <svg> does not
B. <canvas> is for interactive graphics, while <svg> is static
C. <canvas> draws graphics with JavaScript, while <svg> uses XML
D. <canvas> is older than <svg>
Q.109 In the context of HTML5’s Drag and Drop API, what does the dataTransfer object do?
A. Transfers data between drag and drop operations
B. Changes the style of the dragged element
C. Controls the draggable properties of elements
D. Plays a role in touch−screen interactions
Q.110 What is the purpose of the HTML5 Canvas API?
A. To create draggable elements
B. To embed video content
C. To draw graphics via scripting
D. To add animations to text
Q.111 Spot the error in this responsive design code: HTML: <div class=”mobile”></div> CSS: @media (max−width: 600px) { .desktop { display: none; } }
A. The CSS class does not match the HTML class
B. Incorrect use of max−width
C. The display: none; rule is wrongly applied
D. No error
Q.112 Identify the issue in this CSS media query: @media (min−width: 600px) { p { font−size: 18px; } }
A. It incorrectly uses min−width
B. It doesn’t specify screen height
C. The font size is too large
D. No issue
Q.113 What does this combination of HTML and CSS achieve? HTML: <div class=”container”></div> CSS: .container { display: flex; flex−wrap: wrap; }
A. Creates a fixed layout not affected by screen size
B. Forces all child elements to stay in a single line
C. Creates a responsive container that adjusts its child elements
D. Aligns all child elements to the right
Q.114 How does this HTML and CSS code function? <div class=”responsive”></div> in HTML and .responsive { width: 100%; max−width: 500px; } in CSS
A. It makes the div element stretch to fill 100% of the screen
B. It limits the div width to 500px on all devices
C. It makes the div element responsive to screen size, with a max−width of 500px
D. It creates a fixed−size div not affected by screen size
Q.115 What will this CSS media query do? @media (max−width: 600px) { /Unknown node type: em/ }
A. Apply the CSS rules to screens larger than 600px
B. Apply the CSS rules to screens smaller than 600px
C. Hide content on screens smaller than 600px
D. Change the layout on all devices
Q.116 In responsive design, what is the “mobile−first” approach?
A. Designing a website for mobile devices before desktops
B. Prioritizing mobile functionality over desktop
C. Exclusively designing websites for mobile devices
D. Exclusively designing websites for mobile devices
Q.117 Which HTML5 element is particularly useful for structuring a responsive web design?
A. <div>
B. <span>
C. <section>
D. <article>
Q.118 What does CSS media query primarily allow you to do in terms of responsive design?
A. Change the font size based on the device
B. Load different images on different devices
C. Apply different stylesheets for different devices
D. Control the display of content based on screen size or device
Q.119 In responsive design, what is the purpose of the viewport <meta> tag?
A. To disable zooming on mobile devices
B. To define the width of the website
C. To control the layout on different browsers
D. To set the width of the viewport to match the device’s width
Q.120 What is the primary purpose of responsive web design?
A. To make websites load faster
B. To enhance the security of websites
C. To make websites visually appealing
D. To make websites work well on different devices
Q.121 Identify the problem in this JavaScript code in an HTML file: <ul id=”list”></ul> Script: <script>for (let i = 0; i < 3; i++) { let li = document.createElement(‘li’); li.innerHTML = ‘Item ‘ + i; document.getElementById(‘list’).appendChild(li); }</script>
A. The loop does not create list items correctly
B. The li element is not appended to the ul
C. The script is incorrectly placed in the HTML
D. No issue
Q.122 What is wrong with this HTML and JavaScript integration?<div id=”container”></div> Script: <script>let cont = document.querySelector(‘#container’); cont.addEventListener(‘click’, respondClick); function respondClick() { cont.innerHTML = ‘Clicked!’; }</script>
A. The script should be inside the div
B. querySelector is used incorrectly
C. addEventListener is not set up correctly
D. No issue
Q.123 Spot the mistake in this JavaScript and HTML code:<script>function updateText() { document.getElementByld(‘text’).innerHTML = ‘Updated’; }</script> <p id=’text’>Original Text</p>
A. Incorrect function name updateText
B. Typo in document.getElementByld
C. Wrong method innerHTML
D. Misuse of the script tag
Q.124 Identify the issue in this JavaScript integration with HTML: <button onclick=”showMessage()”>Click Me</button> Script: function showMessage) { alert(“Welcome!”); }
A. The function call in onclick is incorrect
B. The script tag is missing
C. There is a syntax error in the function declaration
D. The alert function is used incorrectly
Q.125 How does this JavaScript interact with HTML? <input id=”inputField” type=”text”> <button onclick=
“alert (document.getEleementById(‘inputField’).value);”>Alert Value</button>
A. Displays the value of the input field in an alert when the button is clicked
B. Changes the input field value to ‘Alert Value’ when clicked
C. Creates a new input field when the button is clicked
D. Reloads the page with the input field value
Q.126 What does this JavaScript code achieve? <script>document.getElementById(‘demo’).innerHTML =
‘Welcome!’;</script>
A. Changes the content of the element with id ‘demo’ to ‘Welcome!’
B. Displays an alert with ‘Welcome!’
C. Changes the title of the document to ‘Welcome!’
D. Creates a new element with the text ‘Welcome!’
Q.127 What is the result of this JavaScript in an HTML page? <script>let elem = document.createElement(‘div’); document.body.appendChild(elem);</script>
A. Creates a new div and adds it to the end of the document body
B. Deletes all div elements from the document body
C. Changes the style of the first div element
D. Reloads the body of the document
Q.128 How does this JavaScript function work? <button onclick=”changeColor()”>Click Me</button> Script: function changeColor() { document.body.style.backgroundColor = ‘blue’; }
A. It changes the color of the button
B. It changes the background color of the body to blue
C. It creates a pop−up with the text “blue”
D. It changes the color of all text to blue
Q.129 What will this JavaScript code do when added to an HTML file? <script>document.write(“Hello, World!”);</script>
A. It will write “Hello, World!” on the document
B. It will create an alert saying “Hello, World!”
C. It will comment out “Hello, World!” in the HTML
D. It will delete all content and write “Hello, World!”
Q.130 What is the role of Promises in JavaScript?
A. To provide a way to execute synchronous callbacks
B. To delay the execution of a JavaScript function
C. To handle asynchronous operations
D. To repeat an operation a set number of times
Q.131 How does JavaScript’s fetch API enhance web application functionality?
A. By allowing synchronous web page updates
B. By enabling data retrieval without refreshing the page
C. By solely sending data to a server
D. By improving JavaScript execution speed
Q.132 What is the purpose of using AJAX in JavaScript?
A. To create asynchronous web applications
B. To increase the server loading time
C. To reload the whole webpage for content update
D. To animate HTML elements
Q.133 In JavaScript, what does the addEventListener method do?
A. Adds new HTML elements
B. Updates the CSS of an element
C. Listens for events on HTML elements
D. Changes the attributes of HTML elements
Q.134 How does JavaScript interact with HTML DOM?
A. By changing the file structure of HTML
B. By externally linking to HTML elements
C. By dynamically altering HTML elements and their styles
D. By reloading the page with new HTML content
Q.135 Which JavaScript method is commonly used to manipulate the content of an HTML element?
A. document.getElementByContent()
B. document.getElementById()
C. document.setContent()
D. document.changeHTML()
Q.136 What is the primary purpose of JavaScript in web development?
A. To structure web content
B. To style web pages
C. To add interactivity to web pages
D. To improve the website’s loading time
Q.137 How do you link a JavaScript file to an HTML document?
A. Using the <link> tag
B. Using the <script> tag
C. Using the <javascript> tag
D. Using inline JavaScript in the HTML file
Q.138 What’s the problem with this HTML and CSS? HTML: <div class=”main”>Content</div> CSS: .main
{ display: inline−block; width: 100%; }
A. display: inline−block cannot be used with width: 100%
B. The class name in CSS does not match the HTML
C. width: 100% is invalid for a div
D. No issue
Q.139 Identify the issue in this HTML and CSS combination: HTML: <div class=”button”>Click Me</div>
CSS: .button { color: white; background−color: green; padding: 10px; border−radius; }
A. Missing value for border−radius
B. Incorrect syntax for color property
C. background−color should be background
D. No issue
Q.140 Spot the error in this CSS code: .nav { float: left; width: 50%; } .content { margin−left: 50%; }
A. The .nav class should use margin−left instead of float
B. The width of .nav should be less than 50%
C. .content should have float: left too
D. No error
Q.141 Identify the issue in this HTML and CSS integration: HTML: <div class=”header”></div> CSS: #header { background−color: blue; }
A. The CSS selector is incorrect
B. The background color is not valid
C. The div should have an id, not a class
D. There is no issue
Q.142 What does this CSS flexbox code accomplish? .flex−container { display: flex; justify−content: space−between; }
A. Distributes items in the container evenly
B. Aligns items vertically in the container
C. Spaces out items evenly in the container
D. Creates equal space around each item in the container
Q.143 How does this CSS snippet work? a:hover { color: red; }
A. Changes the color of all links to red
B. Makes a link red when it’s clicked
C. Turns a link red when the mouse hovers over it
D. Underlines a link when hovered
Q.144 What is achieved by this CSS code? .container { margin: 0 auto; width: 80%; }
A. Centers the container on the page and sets its width to 80%
B. Makes the container take up 80% of the screen height
C. Applies a margin of 0 to all sides of the container
D. Creates a container with a fixed width and variable margin
Q.145 How does this CSS rule function? #header { width: 100%; height: 50px; background−color: #333; }
A. It creates a header with a fixed size and a dark background
B. It changes the color of all text in the header
C. It sets the width of the header to the width of its parent element
D. Both A and C
Q.146 What does this CSS code do? body { font−family: Arial, sans−serif; }
A. Changes the background of the body element
B. Sets the default font of the entire document to Arial, sans−serif
C. Makes the text in the body element bold
D. Applies a font only to the body element’s direct children
Q.147 What is the purpose of using the !important rule in a CSS declaration?
A. To increase the loading priority of the CSS file
B. To make a style inheritable by child elements
C. To override other styles regardless of specificity
D. To mark a style as crucial for browser compatibility
Q.148 How do CSS media queries enhance the responsiveness of a website?
A. By loading different websites on different devices
B. By changing the website’s content based on the device
C. By applying different styles based on device characteristics
D. By altering the site’s structure depending on user interaction
Q.149 In CSS, what is the difference between the id selector and the class selector?
A. id applies to only one element, class can be used on multiple elements
B. id is used for JavaScript, class is used for styling
C. id has higher specificity than class
D. Both A and C
Q.150 What is the function of the CSS display property?
A. To control the opacity of an element
B. To manipulate the position of an element
C. To change the way an element is displayed
D. To adjust the color of an element