Learn with Yasir

Share Your Feedback

HTML Basics MCQs: Test Your Knowledge with Multiple-Choice Questions


HTML Basics MCQs: Test Your Knowledge with Multiple-Choice Questions

  1. Which HTML element contains metadata like the page title and links to stylesheets?

    • A) <body>
    • B) <head>
    • C) <title>
    • D) <meta>

Answer: B) <head>


2. What is the purpose of the <title> element in an HTML document?

a) Displays a heading on the webpage
b) Defines the title shown on the browser tab
c) Adds a tooltip to elements
d) Creates a paragraph

Answer: b) Defines the title shown on the browser tab


3. Which element is used to structure the main visible content of a webpage?

a) <head>
b) <body>
c) <title>
d) <meta>

Answer: b) <body>


4. What is the correct way to define a paragraph in HTML?

a) <para>
b) <p>
c) <paragraph>
d) <pg>

Answer: b) <p>


5. Which heading element is the largest by default?

a) <h6>
b) <h3>
c) <h1>
d) <h5>

Answer: c) <h1>


6. What is the purpose of the <br> tag in HTML?

a) Creates a horizontal line
b) Breaks text into a new paragraph
c) Creates a line break
d) Bolds text

Answer: c) Creates a line break


7. Which tag is used to create a horizontal line in HTML?

a) <hr>
b) <br>
c) <line>
d) <hl>

Answer: a) <hr>


8. Which attribute is required in the <img> tag to specify the image file?

a) alt
b) src
c) href
d) title

Answer: b) src


9. What is the purpose of the <em> tag?

a) Makes text bold
b) Makes text italicized for emphasis
c) Creates a new paragraph
d) Underlines text

Answer: b) Makes text italicized for emphasis


11. What is the purpose of the <code> tag?

a) Displays a preformatted block of code
b) Highlights text in yellow
c) Creates a clickable button
d) Creates a hyperlink

Answer: a) Displays a preformatted block of code


12. Which tag is used to display a blockquote in HTML?

a) <q>
b) <blockquote>
c) <cite>
d) <quote>

Answer: b) <blockquote>


13. The <pre> tag is used to…

a) Add metadata to the HTML document
b) Preserve whitespace and formatting in text
c) Highlight text
d) Create a paragraph

Answer: b) Preserve whitespace and formatting in text


14. What is the main difference between inline and block elements?

a) Inline elements take up full width, block elements do not
b) Block elements always have a border
c) Inline elements do not start on a new line, block elements do
d) There is no difference

Answer: c) Inline elements do not start on a new line, block elements do


15. Which of the following is an example of an inline element?

a) <h1>
b) <p>
c) <em>
d) <blockquote>

Answer: c) <em>

Here are more multiple-choice questions (MCQs) on HTML elements:


16. Which of the following is a block-level element?

a) <span>
b) <strong>
c) <div>
d) <em>

Answer: c) <div>


17. What is the correct HTML tag for emphasizing text with strong importance?

a) <b>
b) <strong>
c) <i>
d) <u>

Answer: b) <strong>


18. What does the <img> tag require to display an image?

a) href
b) alt
c) src
d) title

Answer: c) src


19. The <p> tag in HTML is used for?

a) Adding paragraphs
b) Creating tables
c) Displaying images
d) Creating lists

Answer: a) Adding paragraphs


21. What happens when you use the <br> tag?

a) Adds a horizontal line
b) Adds a page break
c) Inserts a line break
d) Bolds text

Answer: c) Inserts a line break


22. What is the difference between <b> and <strong> tags?

a) <b> is obsolete, <strong> is not
b) <strong> indicates importance, <b> only makes text bold
c) <b> is used for larger text, <strong> is for emphasis
d) There is no difference

Answer: b) <strong> indicates importance, <b> only makes text bold


23. Which element is used to display preformatted text with spaces and line breaks preserved?

a) <p>
b) <pre>
c) <blockquote>
d) <code>

Answer: b) <pre>


24. Which of the following tags is used for inline styling and content grouping?

a) <div>
b) <span>
c) <section>
d) <article>

Answer: b) <span>


25. Which tag is used to create a long quotation in HTML?

a) <q>
b) <blockquote>
c) <quote>
d) <cite>

Answer: b) <blockquote>


28. What is the purpose of the alt attribute in the <img> tag?

a) Adds a caption to the image
b) Provides alternative text for accessibility
c) Changes the image size
d) Links the image to another page

Answer: b) Provides alternative text for accessibility


29. Which of the following is an example of a self-closing (void) element in HTML?

a) <p>
b) <div>
c) <br>
d) <span>

Answer: c) <br>


30. What is the default display property of the <p> tag?

a) Inline
b) Inline-block
c) Block
d) Flex

Answer: c) Block


31. Which tag is used to group elements into a logical section in HTML?

a) <div>
b) <span>
c) <p>
d) <br>

Answer: a) <div>


32. What does the <em> tag do to the enclosed text?

a) Makes it bold
b) Italicizes it for emphasis
c) Underlines it
d) Highlights it

Answer: b) Italicizes it for emphasis


33. What is the correct way to display a comment in HTML?

a) // This is a comment
b) /* This is a comment */
c) <!-- This is a comment -->
d) <comment>This is a comment</comment>

Answer: c) <!-- This is a comment -->


35. What happens if an image file specified in the <img> tag’s src attribute is missing?

a) The browser shows an error message
b) The image is replaced with a broken image icon
c) The page does not load
d) Nothing happens

Answer: b) The image is replaced with a broken image icon


38. Which tag is used to display a citation in HTML?

a) <cite>
b) <blockquote>
c) <q>
d) <cite>

Answer: a) <cite>


34. Which tag is used to define a section of content that is self-contained?

a) <div>
b) <section>
c) <article>
d) <header>

Answer: c) <article>


⭐️ HTML Contents

Learn the basics of HTML, including elements, attributes and forms controls.