MCQs Of Class 18
Best Practices for Writing HTML
1. Which of the following is a semantic HTML element?
a) <div>
b) <span>
c) <article>
d) <img>
Answer: c) <article>
Explanation: <article> is a semantic element that represents a
self-contained piece of content, making it more meaningful for both browsers
and developers.
2. What is the purpose of the alt attribute in an image tag?
a) To provide a description of the image for accessibility
b) To change the image source
c) To add a caption under the image
d) To set the image's width
Answer: a) To provide a description of the image for accessibility
Explanation: The alt attribute provides alternative text for users who cannot
see the image (e.g., screen readers).
3. Which tag is used to define the header of a document or section?
a) <footer>
b) <header>
c) <head>
d) <nav>
Answer: b) <header>
Explanation: The <header> element is used to define introductory content,
often including navigation links and a logo.
4. What is the correct purpose of the <footer> tag?
a) To define the document title
b) To define the bottom section of a page or section
c) To create a navigation bar
d) To set the background of a page
Answer: b) To define the bottom section of a page or section
Explanation: The <footer> tag defines footer content, typically
containing contact information, copyrights, and links.
5. Which of the following HTML elements is deprecated?
a) <section>
b) <font>
c) <article>
d) <nav>
Answer: b) <font>
Explanation: The <font> element is deprecated, and its styling should now
be done using CSS.
6. Which tag is used for defining a navigation menu?
a) <menu>
b) <nav>
c) <section>
d) <list>
Answer: b) <nav>
Explanation: The <nav> element is used to define navigation links on a
webpage.
7. What does the aria-label attribute do?
a) Adds a label to an image
b) Improves accessibility for screen readers by providing an accessible name
c) Specifies the target of a link
d) Defines a label for form elements
Answer: b) Improves accessibility for screen readers by providing
an accessible name
Explanation: The aria-label attribute gives an accessible name to an element
for users with disabilities.
8. What is the function of the <main> element in HTML?
a) To define the main content of the document
b) To include navigation links
c) To provide header content
d) To define metadata for the document
Answer: a) To define the main content of the document
Explanation: The <main> element is used to define the primary content of
a webpage, excluding headers, footers, and sidebars.
9. What should you use to align content in the center of a page
instead of the <center> tag?
a) CSS text-align property
b) CSS align-content property
c) HTML <center> tag
d) <div> with inline style
Answer: a) CSS text-align property
Explanation: The <center> tag is deprecated, and CSS should be used for
centering content using the text-align: center; property.
10. Why is it important to use semantic HTML elements?
a) For better styling
b) For improved accessibility and SEO
c) To make the code look cleaner
d) To reduce file size
Answer: b) For improved accessibility and SEO
Explanation: Semantic HTML elements provide meaning to the content, improving
accessibility and SEO by making the structure clear to both humans and search
engines.
