CBSE Class 10 Computer Applications Question 25 of 37

Cascading Style Sheets (CSS) — Question 5

Back to all questions
5
Question

Question 5

How do you link an external stylesheet to a page.

  1. <link href='somefile.css'>
  2. <link rel='stylesheet' src='somefile.css'>
  3. <script rel='stylesheet' href=' somefile.css'> </script>
  4. <link rel='stylesheet' href='somefile.css'>
Answer

<link rel='stylesheet' href='somefile.css'>

Reason — The correct syntax is explained below:

  • <link> is an HTML tag used to include external resources, such as stylesheets.
  • rel='stylesheet' is an attribute that specifies the relationship between the current document and the linked resource. In this case, it indicates that the linked resource is a stylesheet.
  • href='somefile.css' is the attribute that specifies the location (URL or file path) of the external CSS file. In this case, it points to a file named "somefile.css".

By using this <link> tag with the correct attributes, we can connect an external CSS file (such as "somefile.css") to our HTML document, allowing the styles defined in the CSS file to be applied to the web page.