1. Which HTML tag is used to create an ordered list?
Step-by-Step Explanation
<ul> creates an unordered list (bullet points).
<ol> creates an ordered list (numbered list).
<dl> creates a description list.
<li> is used to define a list item within both ordered and unordered lists.
Answer: c) <ol> ✅
2. What is the primary purpose of the alt attribute in the HTML <img> tag?
Step-by-Step Explanation
The `alt` attribute is crucial for accessibility. It provides a text description of the image, which is displayed if the image fails to load or for users with visual impairments who rely on screen readers.
Alignment, dimensions, and background colors can be set using CSS or other attributes, but `alt` is strictly for alternative text.
Answer: b) To provide alternative text for the image if it cannot be displayed. ✅
3. Which HTML tag is used to create a hyperlink?
Step-by-Step Explanation
The <a> (anchor) tag is used to define hyperlinks. The `href` attribute within the <a> tag specifies the URL of the link.
<link> is used to define the relationship between the current document and an external resource, often a CSS file.
<url> and <href> are not valid HTML tags for creating hyperlinks.
Answer: d) <a> ✅
4. What is the purpose of the <thead>, <tbody>, and <tfoot> tags in an HTML table?
Step-by-Step Explanation
These tags enhance the semantic structure of tables, making them more accessible and easier to style.
<thead> defines the table header, <tbody> defines the table body, and <tfoot> defines the table footer.
While CSS controls the style and appearance, these tags define the logical structure.
Answer: c) To structure the table's header, body, and footer sections. ✅
5. Which HTML tag is used to embed an inline frame?
Step-by-Step Explanation
<iframe> allows you to embed another HTML document within the current document.
<frame> is used in older, deprecated frameset layouts.
<embed> is used to embed external applications or interactive content.
<object> is also used to embed multimedia content, but <iframe> is specifically for embedding HTML documents.
Answer: d) <iframe> ✅
6. Which tag is used to define the title of an HTML document?
Step-by-Step Explanation
The <title> tag is placed within the <head> section of an HTML document and specifies the title that appears in the browser's title bar or tab.
<h1> is used for the main heading of a page's content.
<header> is used to define a header for a document or section.
<head> is a container for metadata (data about data) and is where the title tag resides.
Answer: d) <title> ✅
7. Which tag is used to create a paragraph in HTML?
Step-by-Step Explanation
The <p> tag is used to define a paragraph of text. Browsers automatically add a blank line before and after each paragraph.
<text>, <para> and <line> are not valid HTML tags for creating paragraphs.
Answer: c) <p> ✅
8. What is the purpose of the <meta> tag in HTML?
Step-by-Step Explanation
<meta> tags provide information about the HTML document that is not displayed directly on the page. They are used for various purposes, including specifying character encoding, setting the viewport for responsive design, and providing keywords for search engines.
Styling is done via CSS, main content is within the body tag, and hyperlinks are created using the <a> tag.
Answer: c) To provide metadata about the HTML document, such as character set and viewport settings. ✅
9. Which attribute is used to define an inline style for an HTML element?
Step-by-Step Explanation
The style attribute allows you to add inline CSS styles directly to an HTML element.
class and id are used for applying CSS styles defined in external or internal stylesheets.
src is used to specify the source of an image or other embedded content.
Answer: a) style ✅
10. Which HTML tag is used to create a form?
Step-by-Step Explanation
The <form> tag is used to create an HTML form for user input. It acts as a container for form elements like text fields, buttons, and checkboxes.
<input> is a form element used to create various input fields.
<button> is a form element used to create clickable buttons.
<field> is not a valid HTML tag for creating forms.
Answer: b) <form> ✅
11. What does the colspan attribute in a <td> tag do?
Step-by-Step Explanation
colspan allows a single table cell to occupy the space of multiple columns within a table row.
rowspan does the same for rows.
Color, height, and borders are typically set using CSS.
Answer: b) It specifies the number of columns a cell should span. ✅
12. Which HTML tag is used to define a section of navigation links?
Step-by-Step Explanation
The <nav> tag is used to define a section of navigation links, such as menus or tables of contents. It helps improve the semantic structure of a web page.
<header> defines a header for a document or section.
<section> defines a thematic grouping of content.
<aside> defines content aside from the content it is placed in (like sidebars).
Answer: b) <nav> ✅
13. What is the purpose of the <label> tag in HTML forms?
Step-by-Step Explanation
The <label> tag provides a user-friendly way to associate a text label with an input element, such as a text field or checkbox. It improves accessibility by allowing users to click the label to focus or toggle the associated input.
Buttons are created using <button>, text fields with <input type="text">, and form actions are specified in the <form> tag.
Answer: c) To associate a text label with an input element. ✅
14. Which attribute is used to specify the URL of the page a link goes to?
Step-by-Step Explanation
The href attribute within the <a> (anchor) tag specifies the destination URL of the hyperlink.
src is used for embedded resources like images.
link is a tag used within the <head> tag for external resources.
url is not an HTML attribute.
Answer: d) href ✅
15. What is the purpose of the <fieldset> tag in HTML forms?
Step-by-Step Explanation
The <fieldset> tag is used to group related form elements together, making the form more organized and easier to understand.
Tables are created with <table>, headings with <h1> to <h6>, and submission methods are defined in the <form> tag.
Answer: b) To group related elements in a form. ✅
16. Which HTML tag is used to define a thematic break in an HTML page?
Step-by-Step Explanation
The <hr> (horizontal rule) tag is used to create a thematic break or horizontal line across the page, indicating a change in content.
<break>, <line>, and <space> are not valid HTML tags for this purpose.
Answer: c) <hr> ✅
17. What does the target="_blank" attribute in an <a> tag do?
Step-by-Step Explanation
target="_blank" is commonly used to open external links in a new browser window or tab, preventing the user from navigating away from the current page.
target="_self" (default) opens in the same window/tab.
Popups require JavaScript.
target="_parent" opens in the parent frame.
Answer: b) It opens the link in a new window or tab. ✅
18. What is the primary functionality of the <details> and <summary> elements?
Step-by-Step Explanation
The <details> element creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state.
The <summary> element provides a summary or caption for the content of the <details> element.
When the user clicks the <summary> element, the <details> element is toggled between open and closed states, revealing or hiding its content.
It's not for modal dialogs, tooltips, or tabbed interfaces.
Answer: b) To implement a collapsible section of content.✅