WEB-DEVELOPMENT-FOUNDATION practice question 12 of 15

When should HTML code primarily be used for a web page?

Full set: 75 questions
Answer options
A: When the column width of a table needs to be adjusted for a larger screen
B: When the background color of an input box needs to be yellow
C: When the image for an advertisement needs to be added to a web page Correct answer
D: When the header for a section needs to continuously change size
Correct Answer:
C. When the image for an advertisement needs to be added to a web page
Explanation

HTML's primary role is to define the structure and semantic content of a web page. Adding an image for an advertisement is a content-related task, which is correctly accomplished using the HTML element. This element embeds an image into the document, fulfilling HTML's core purpose of structuring content. The other options describe presentation or behavior, which are the domains of CSS and JavaScript, respectively, following the principle of separation of concerns in web development.

Why Incorrect

A. Adjusting column width for screen size is a responsive layout concern. This is a presentation task best handled by CSS media queries, not HTML structure.
B. Changing the background color of an element is a stylistic choice. This presentation rule should be defined using CSS (background-color property), not HTML.
D. Causing an element to continuously change size is dynamic behavior. This functionality is implemented using JavaScript, often in conjunction with CSS for animations.

References

1. Mozilla Developer Network (MDN) Web Docs: The element page explicitly states, "The HTML element embeds an image into the document." This confirms its role is to add content.

Source: MDN Web Docs, ": The Image Embed element", Section: "Usage". (developer.mozilla.org/en-US/docs/Web/HTML/Element/img)

2. W3C HTML 5.2 Specification: The official standard for HTML defines the img element as the means to represent an image within the document's content.

Source: W3C, "HTML 5.2 Recommendation", Section 4.8.1 "The img element". (www.w3.org/TR/html52/semantics-embedded-content.html#the-img-element)

3. MIT OpenCourseWare: Course materials on web design emphasize the separation of concerns, where HTML is for content/structure, CSS is for presentation (style, layout, colors), and JavaScript is for behavior.

Source: MIT OpenCourseWare, 6.170 Software Studio, Fall 2012, Lecture 12: "HTML/CSS/Javascript", Slide 5 "Separation of Concerns". (ocw.mit.edu)

Scroll to Top