logo

Very Short Question and Answers - HTML Document Structure


Q 1.
What is the purpose of the `<!DOCTYPE html>` declaration in an HTML document?

Ans:

It tells the browser which version of HTML is being used; specifically, it declares that the document is HTML5.

Q 2.
Where is the `<!DOCTYPE html>` declaration placed in an HTML document?

Ans:

It is placed at the very top of the HTML document, before any other HTML code.

Q 3.
What happens if the Doctype declaration is missing in an HTML document?

Ans:

Browsers may render the page in quirks mode, leading to display problems.

Q 4.
What is the root element of every HTML page?

Ans:

The <html> element is the root element of every HTML page.

Q 5.
Name the two main sections that are always found inside the `<html>` tag.

Ans:

The two main sections are <head> and <body>.

Q 6.
What is the main purpose of the `<head>` section in an HTML document?

Ans:

It contains metadata or information about the document that isn't displayed directly on the web page.

Q 7.
List two common elements that are placed inside the `<head>` section.

Ans:

Common elements include <title> for the page title and <meta> for metadata.

Q 8.
What does the `<title>` tag do in an HTML document?

Ans:

It sets the title of the page, which appears on the browser tab.

Q 9.
What is the function of the `<body>` section in an HTML document?

Ans:

It contains all the content that is visible to the user, such as text, images, and links.

Q 10.
Give two examples of content that can go inside the `<body>` section.

Ans:

Examples include paragraphs (<p>), headings (<h1> to <h6>), images, tables, and lists.

Q 11.
Where is the `<meta charset="UTF-8">` tag placed and what does it do?

Ans:

It is placed inside the <head> section and specifies the character encoding for the document.

Q 12.
Why are meta tags important in HTML?

Ans:

Meta tags provide metadata that assists with SEO, accessibility, search engines, and browser behavior.

Q 13.
How can you specify the language of the HTML document?

Ans:

By using the lang attribute in the <html> tag, e.g., <html lang="en">.

Q 14.
What is the difference between information in the `<head>` and in the `<body>`?

Ans:

<head> contains metadata not directly visible to users, while <body> contains the visible page content.

Q 15.
In which section would you link an external CSS file, and how is this done?

Ans:

In the <head> section, using the <link> tag (e.g., <link rel="stylesheet" href="styles.css">).

Q 16.
What does the `<meta name="viewport" content="width=device-width, initial-scale=1.0">` tag do?

Ans:

It helps control how the webpage is displayed on mobile devices by setting width and scale.

Q 17.
Explain the terms: 'metadata' and 'content' in relation to HTML structure.

Ans:

'Metadata' is data about the webpage placed in <head>; 'content' is information shown to users in <body>.

Q 18.
What would you call the `<html>` element in the context of HTML document structure?

Ans:

It is called the root or container element of the HTML document.

Q 19.
What is the significance of specifying character encoding using `<meta charset="UTF-8">`?

Ans:

It ensures that the browser correctly displays all characters, symbols, and languages on the page.

Q 20.
How did HTML5 improve the use of Doctype and meta tags compared to older versions?

Ans:

HTML5 made the Doctype simpler and more universal, and made meta tags more powerful and essential for modern web development.