Back to the 2023 paper

Module I: Introduction to Web Technologies & Architectures

20232m

Which of the following is the correct syntax for adding an external style sheet?

(i) <style href='main.css'></style>
(ii) <style src='main.css'></style>
(iii) <link rel='stylesheet' type='text/css' src='main.css'>
(iv) <link rel='stylesheet' type='text/css' href='main.css'>

Worked SolutionAI Assisted

Answer

(iv) <link rel='stylesheet' type='text/css' href='main.css'>

Step-by-step

  1. An external stylesheet is attached with the HTML <link> element.
  2. rel="stylesheet" identifies the linked resource as a stylesheet.
  3. href="main.css" specifies the CSS file location.
  4. src is not the attribute used by <link> for the stylesheet URL.

Example

<link rel="stylesheet" href="main.css">

Final answer: (iv)

Similar questions