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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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)?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
Explanation:
Comments in HTML are wrapped between <!– and –>.
12. Which attribute is used to create a link that opens a new browser window?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
Explanation:
The style attribute is used to apply inline styles to HTML elements.
22. What does the <aside> element represent in HTML5?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
Explanation:
The <html> tag represents the root of an HTML document.
29. Which attribute specifies the character encoding for an HTML document?
Answer:
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?
Answer:
Explanation:
Checkboxes can be grouped using the same name attribute value.
31. How do you mark up a navigational section in HTML5?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
Explanation:
The ismap attribute is used to specify an image as a server-side image-map.