Web Development
1. Which of the following best describes the primary function of Hypertext
Markup Language (HTML) in web development?
A) To define the visual styling and layout of a webpage
B) To create the structure and content of a webpage
C) To add interactivity and dynamic behavior to a webpage
D) To manage server-side databases and user authentication
Correct Answer: To create the structure and content of a webpage
Rationale: HTML is the standard markup language used to create the
structure and content of web pages. It defines headings, paragraphs, links,
images, and other elements. CSS handles styling and layout, while JavaScript
adds interactivity and dynamic behavior.
2. In the client-server model of the World Wide Web, what is the primary role
of the client?
A) To store and serve web pages to users
B) To request and render web pages from servers
C) To manage domain name resolution
D) To host databases and application logic
Correct Answer: To request and render web pages from servers
Rationale: In the client-server model, the client (typically a web browser)
sends requests to servers and renders the received web pages for the user.
Servers store and serve the content. Clients do not host databases or
manage DNS.
,3. A web developer is creating an HTML document. Which tag is used to
define the document type and version of HTML being used?
A) `<html>`
B) `<!DOCTYPE html>`
C) `<head>`
D) `<meta>`
Correct Answer: `<!DOCTYPE html>`
Rationale: The `<!DOCTYPE html>` declaration is used to specify the
document type and version of HTML. For HTML5, it is simply `<!DOCTYPE
html>`. This must be the first line in the document to ensure proper
rendering by browsers.
4. Which HTML element is used to contain metadata about the webpage,
such as the title, character encoding, and links to external stylesheets?
A) `<body>`
B) `<head>`
C) `<header>`
D) `<footer>`
Correct Answer: `<head>`
Rationale: The `<head>` element contains metadata about the HTML
document. This includes the `<title>`, `<meta>` tags for character
encoding and viewport settings, and `<link>` tags for external stylesheets.
The `<body>` contains the visible content.
5. What is the purpose of the `<title>` tag within the `<head>` section of
an HTML document?
,A) To display a heading on the webpage itself
B) To define the text that appears in the browser's title bar or tab
C) To create a tooltip when hovering over an element
D) To specify the filename of the HTML document
Correct Answer: To define the text that appears in the browser's title bar or
tab
Rationale: The `<title>` tag specifies the title of the web page, which is
displayed in the browser's title bar or tab. It is also used by search engines
and as the default name when bookmarking the page.
6. Which HTML attribute is used to provide a unique identifier for an element,
allowing it to be targeted by CSS and JavaScript?
A) `class`
B) `id`
C) `name`
D) `style`
Correct Answer: `id`
Rationale: The `id` attribute provides a unique identifier for an HTML
element. Unlike `class`, which can be applied to multiple elements, an `id`
must be unique within the page. It is commonly used for CSS styling and
JavaScript DOM manipulation.
7. A developer wants to apply the same CSS styling to multiple elements on
a page. Which HTML attribute should be used?
A) `id`
, B) `style`
C) `class`
D) `name`
Correct Answer: `class`
Rationale: The `class` attribute is used to assign one or more class names to
an element, allowing multiple elements to share the same CSS styles. An `id`
must be unique, while `class` can be reused across many elements.
8. Which HTML element is used to create a hyperlink to another webpage or
resource?
A) `<link>`
B) `<a>`
C) `<href>`
D) `<nav>`
Correct Answer: `<a>`
Rationale: The `<a>` (anchor) element is used to create hyperlinks. The
`href` attribute specifies the destination URL. The `<link>` element is used
for external resources like stylesheets, and `<nav>` defines a navigation
section.
9. What is the correct HTML syntax for creating an image on a webpage?
A) `<image src="photo.jpg">`
B) `<img src="photo.jpg" alt="Description">`
C) `<picture src="photo.jpg">`
D) `<img href="photo.jpg">`