WEB-DEVELOPMENT-FOUNDATION practice question 14 of 15

Which two rules can be validated with the W3C Markup Validation Service? Choose 2 answers.

Full set: 75 questions
Answer options
A:

A. - omitted

B:

B. <! DOCTYPE> omitted

Correct answer
C:

C. alt attribute omitted from <img> q <article> omitted


Correct answer
D:

D. border attribute omitted from <table>

Correct Answer:
B. B. <! DOCTYPE> omitted; C. C. alt attribute omitted from <img> q <article> omitted
Explanation

The W3C Markup Validation Service checks if a document's markup conforms to the official standards for HTML.
1. omitted: The declaration is a mandatory preamble for all HTML documents. It informs the browser about the version of HTML used, which is crucial for rendering the page in standards mode. Its absence is a fundamental error that will cause the document to fail validation.
2. alt attribute omitted from : The alt attribute is required for the element in HTML5. It provides essential alternative text for accessibility, used by screen readers and when the image cannot be displayed. The W3C validator enforces this as a strict requirement for a valid document.

Why Incorrect

A.

omitted: In HTML5, the closing

tag is optional in many contexts, as the browser's parser can infer its closure. Its omission is not inherently an error.

D. border attribute omitted from

: The border attribute is an obsolete presentational attribute. Modern best practice is to use CSS for styling. Omitting this attribute is correct and will not cause a validation error.

References

1. W3C HTML 5.2 Recommendation (14 December 2017):

Section 4.1.1 The DOCTYPE: States, "A DOCTYPE is a required preamble." This confirms that omitting the is a validation error.

Section 4.8.4.1 The img element: Specifies the requirements for the alt attribute, stating, "The alt attribute must be present...". This confirms that omitting the alt attribute is a validation error.

Section 4.5.1 The p element: Notes on tag omission, "A p element's end tag can be omitted if the p element is immediately followed by [another block-level element]...". This shows the closing tag is not always required.

Section 4.10.1 The table element: Lists the border attribute and explicitly notes, "The border attribute on the table element is obsolete. Use the CSS border property instead." This confirms omitting it is not an error.

2. MDN Web Docs (Mozilla):

: "In HTML, the doctype is a required preamble... If omitted, browsers use a different rendering mode that is incompatible with some specifications..." (See: https://developer.mozilla.org/en-US/docs/Glossary/Doctype)

: The Image Embed element: Under the alt attribute section, it states, "The alt attribute is required for the element." (See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#alt)

Scroll to Top