HTML MCQ

Starting your web development journey? Test your understanding of the basics of HTML with these 40 multiple-choice questions. Each question is followed by its answer and an explanation to reinforce the concept. Let’s dive in!

1. What does HTML stand for?

A. Hyper Transfer Markup Language
B. Hyper Text Markup Language
C. Hyperlinking Text Management Language
D. High-level Text Managing Language

Answer:

B. Hyper Text Markup Language

Explanation:

HTML stands for Hyper Text Markup Language, a standard markup language to create web pages.

2. Which element defines the main content of an HTML document?

A. <body>
B. <header>
C. <main>
D. <head>

Answer:

A. <body>

Explanation:

The <body> element encompasses the main content of an HTML document, essentially what's visible to the user.

3. Which of the following elements defines the head of the document?

A. <head>
B. <header>
C. <top>
D. <main>

Answer:

A. <head>

Explanation:

The <head> element contains meta-information about the document, such as its title and links to its scripts and styles.

4. How do you create a hyperlink in HTML?

A. <link href="www.example.com">Example</link>
B. <a href="www.example.com">Example</a>
C. <web href="www.example.com">Example</web>
D. <hl href="www.example.com">Example</hl>

Answer:

B. <a href="www.example.com">Example</a>

Explanation:

The <a> tag, paired with the href attribute, is used to define hyperlinks in HTML.

5. Which element in HTML can be used to insert a line break?

A. <lb>
B. <break>
C. <br>
D. <newline>

Answer:

C. <br>

Explanation:

The <br> element is employed to induce a line break or initiate a new line in the content.

6. What attribute should be used in the <img> tag to display alternative text if the image fails to load?

A. description
B. text
C. placeholder
D. alt

Answer:

D. alt

Explanation:

The alt attribute provides an alternative text description for an image, aiding in accessibility and informing the user about the image if it doesn't load.

7. Which tag creates a numbered list?

A. <ul>
B. <ol>
C. <dl>
D. <li>

Answer:

B. <ol>

Explanation:

The <ol> element is used to define an ordered list, and the list items inside are represented using the <li> tag.

8. Which HTML element is used to define the title of the document (visible in the browser's title bar or tab)?

A. <meta>
B. <title>
C. <tab>
D. <header>

Answer:

B. <title>

Explanation:

The <title> tag is used to specify the title of the web page, which is visible in the browser's title bar or tab.

9. Which tag is used to input data from the user in a form?

A. <userinput>
B. <input>
C. <textfield>
D. <dataentry>

Answer:

B. <input>

Explanation:

The <input> element is versatile and used for various form controls, from text fields to radio buttons.

10. Which element is used to insert a line horizontally on your web page?

A. <hl>
B. <line>
C. <break>
D. <hr>

Answer:

D. <hr>

Explanation:

The <hr> element is used to define a thematic break or a horizontal rule, typically used for separating content.

11. How is a comment written in HTML?

A. //This is a comment//
B. /*This is a comment*/
C. –This is a comment–
D. <!–This is a comment–>

Answer:

D. <!–This is a comment–>

Explanation:

Comments in HTML are wrapped between <!– and –>.

12. Which attribute is used to create a link that opens a new browser window?

A. new
B. open
C. window="new"
D. target="_blank"

Answer:

D. target="_blank"

Explanation:

The target="_blank" attribute ensures that the linked document opens in a new window or tab.

13. Which HTML tag is used for creating an unordered list?

A. <ul>
B. <li>
C. <ol>
D. <uol>

Answer:

A. <ul>

Explanation:

The <ul> tag is used to define an unordered list, and the list items inside are represented using the <li> tag.

14. Which of the following HTML elements represents emphasized text?

A. <em>
B. <i>
C. <strong>
D. <highlight>

Answer:

A. <em>

Explanation:

The <em> element is used to emphasize text. This usually results in the text being displayed in italics.

15. What does the <meta> tag provide?

A. Metadata about the HTML document.
B. An animation.
C. A paragraph of text.
D. A table structure.

Answer:

A. Metadata about the HTML document.

Explanation:

The <meta> tag provides metadata about the HTML document, such as character set, viewport settings, author, and more.

16. Which HTML tag is used to specify a footer for a document or a section?

A. <bottom>
B. <footer>
C. <end>
D. <sectionend>

Answer:

B. <footer>

Explanation:

The <footer> tag is used to define a footer for a document or a section.

17. What tag is used in HTML to create a dropdown list?

A. <list>
B. <drop>
C. <dl>
D. <select>

Answer:

D. <select>

Explanation:

The <select> tag is used to create a dropdown list in HTML. The options in the dropdown are defined using the <option> tag.

18. How do you create a text area in an HTML form for user comments?

A. <input type="text">
B. <comment>
C. <input type="textbox">
D. <textarea>

Answer:

D. <textarea>

Explanation:

The <textarea> tag is used to define a multi-line input control, like a comment section.

19. Which of the following is the correct way to add a background color in HTML?

A. <body bgcolor="yellow">
B. <body style="background-color:yellow;">
C. <background>yellow</background>
D. <body background-color="yellow">

Answer:

B. <body style="background-color:yellow;">

Explanation:

Modern HTML practices recommend using CSS for styling. Thus, the style attribute with the property "background-color" is the right way.

20. Which of these tags are all <table> tags?

A. <table><head><tfoot>
B. <table><tr><td>
C. <thead><body><tr>
D. <table><th><cap>

Answer:

B. <table><tr><td>

Explanation:

The <table> element is used to create a table. <tr> is used to define a table row, and <td> defines a table data cell.

21. Which HTML attribute is used to define styles inline?

A. styles
B. stylesheet
C. type
D. style

Answer:

D. style

Explanation:

The style attribute is used to apply inline styles to HTML elements.

22. What does the <aside> element represent in HTML5?

A. A main content in the document.
B. A navigation bar.
C. Content aside from the main content.
D. A footer.

Answer:

C. Content aside from the main content.

Explanation:

The <aside> element is used to represent content that's separate from the main content and can be considered independently.

23. Which tag defines a hyperlink, or a link to another page?

A. <hyperlink>
B. <link>
C. <hl>
D. <a>

Answer:

D. <a>

Explanation:

The <a> tag, short for "anchor", is used to define hyperlinks in HTML.

24. How would you define a section heading in an HTML document?

A. <h1>
B. <head>
C. <heading>
D. <section>

Answer:

A. <h1>

Explanation:

HTML provides six levels of headings, from <h1> to <h6>. <h1> defines the most important heading, while <h6> defines the least important.

25. What does the <abbr> tag in HTML denote?

A. A bold text.
B. A block of code.
C. An abbreviation or an acronym.
D. An address.

Answer:

C. An abbreviation or an acronym.

Explanation:

The <abbr> tag is used for abbreviations or acronyms. The full form can be provided using the title attribute.

26. Which of the following is the correct way to comment out multiple lines in HTML?

A. //This is a comment//
B. /*This is a comment*/
C. –This is a comment–
D. <!–This is a comment–>

Answer:

D. <!–This is a comment–>

Explanation:

In HTML, multiple lines can be commented out using <!– to start the comment and –> to end it.

27. What tag in HTML is used to define an internal style sheet?

A. <script>
B. <style>
C. <css>
D. <stylesheet>

Answer:

B. <style>

Explanation:

To define an internal style sheet, you use the <style> tag within the <head> section.

28. Which of the following elements represents the root of an HTML document?

A. <root>
B. <html>
C. <web>
D. <base>

Answer:

B. <html>

Explanation:

The <html> tag represents the root of an HTML document.

29. Which attribute specifies the character encoding for an HTML document?

A. encode
B. charset
C. character
D. set

Answer:

B. charset

Explanation:

The charset attribute specifies the character encoding for the HTML document.

30. What is the correct way to group checkboxes using a common name?

A. <input type="checkbox" name="commonName">
B. <checkbox name="commonName">
C. <input type="box" group="commonName">
D. <check group="commonName">

Answer:

A. <input type="checkbox" name="commonName">

Explanation:

Checkboxes can be grouped using the same name attribute value.

31. How do you mark up a navigational section in HTML5?

A. <navigate>
B. <navigation>
C. <navbar>
D. <nav>

Answer:

D. <nav>

Explanation:

The <nav> element in HTML5 represents a section of navigation links.

32. Which of the following HTML elements would you use to embed a video file into a webpage?

A. <movie>
B. <media>
C. <mp4>
D. <video>

Answer:

D. <video>

Explanation:

The <video> element is used to embed video files into a webpage.

33. What would you use to define a JavaScript function in an HTML document?

A. <javascript>
B. <function>
C. <script>
D. <jsfunction>

Answer:

C. <script>

Explanation:

The <script> tag is used to define client-side JavaScript in an HTML document.

34. Which tag allows you to add a row in an HTML table?

A. <row>
B. <line>
C. <tr>
D. <tdr>

Answer:

C. <tr>

Explanation:

The <tr> tag is used to define a table row in HTML.

35. How do you specify that the text input field should be disabled?

A. <input type="text" disabled="disabled">
B. <input type="text" inactive="true">
C. <input type="text" deactivate="yes">
D. <input type="text" noinput="true">

Answer:

A. <input type="text" disabled="disabled">

Explanation:

The disabled attribute makes an input field uneditable and unresponsive.

36. In HTML5, which tag is used for graphics and graphical applications that can be drawn on the fly, typically with JavaScript?

A. <canvas>
B. <draw>
C. <graphic>
D. <art>

Answer:

A. <canvas>

Explanation:

The <canvas> element is used for graphics that can be drawn on the fly, usually with JavaScript.

37. Which of the following is the correct way to link an external CSS file?

A. <link rel="stylesheet" type="text/css" href="mystyle.css">
B. <style src="mystyle.css">
C. <css source="mystyle.css">
D. <stylesheet link="mystyle.css">

Answer:

A. <link rel="stylesheet" type="text/css" href="mystyle.css">

Explanation:

The <link> tag, with appropriate attributes, is used to link an external stylesheet to an HTML document.

38. What does the http-equiv attribute specify in the <meta> tag?

A. The character set for the document.
B. The author of the document.
C. An HTTP header for the information/value of the content attribute.
D. The viewport settings of the document.

Answer:

C. An HTTP header for the information/value of the content attribute.

Explanation:

The http-equiv attribute provides an HTTP header for the information/value of the content attribute.

39. What tag would you use to ensure the text displays exactly as written, respecting both spaces and line breaks?

A. <pre>
B. <verbatim>
C. <literal>
D. <preserve>

Answer:

A. <pre>

Explanation:

The <pre> tag is used to define preformatted text. The text inside a <pre> tag is displayed in a fixed-width font, and whitespace inside this element is displayed as written.

40. How do you specify the image as a server-side image-map in HTML?

A. <img src="img.jpg" usemap="map">
B. <img src="img.jpg" serverside="map">
C. <img src="img.jpg" ismap>
D. <img src="img.jpg" maptype="server">

Answer:

C. <img src="img.jpg" ismap>

Explanation:

The ismap attribute is used to specify an image as a server-side image-map.


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top