HTML & CSS Interview Question #4
What is the basic structure of an HTML document?
HTML Fundamentals, Structure, Semantics, Links, Images, Tables & Forms Junior Beginner
Quick Interview Answer
A basic HTML document contains a DOCTYPE followed by the html root element. The head contains document metadata and linked resources, while the body contains the page content presented to the user.
Detailed Explanation
A basic HTML document contains a DOCTYPE followed by the html root element. The head contains document metadata and linked resources, while the body contains the page content presented to the user.
The lang attribute on the html element should identify the primary language of the page because it helps browsers, search engines, translation tools, and assistive technologies.
Code Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>My Website</title>
</head>
<body>
<h1>Welcome</h1>
</body>
</html>