In HTML how to import an external CSS file ?

To import an external CSS file into your HTML document, you can use the link element within the head section of your HTML file.

<link rel="stylesheet" href="path_or_url/style.css">

The link element should have the following attributes:

  • rel: specifies the relationship between the HTML document and the linked file. In this case, it should be set to "stylesheet".
  • href: specifies the location of the external CSS file. This can be a relative or absolute path.

Here's an example of how to import an external CSS file called "style.css" located in the same directory as your HTML file:

<!DOCTYPE html>
  <title>My Web Page</title>
  <link rel="stylesheet" href="style.css">
  <!-- Your HTML content goes here -->

Make sure that the file name and path are correct, otherwise, the CSS file won't be loaded, and your HTML document won't be styled as expected.