Sunday, December 29, 2024

How do you add an external style sheet?

 To add an external stylesheet to an HTML document, you use the <link> tag within the <head> section. Here's the syntax:

<head>
  <link rel="stylesheet" href="styles.css">
</head>
  • rel="stylesheet" tells the browser that the linked file is a stylesheet.
  • href="styles.css" is the path to your external CSS file. This can be a relative or absolute URL.

For example, if your styles.css file is located in the same directory as your HTML file, this would be sufficient. If it's in a subfolder, like a css folder, the path would be something like href="css/styles.css".

Make sure the <link> tag is placed inside the <head> section of your HTML document.

No comments:

Post a Comment

How can you refer to a CSS file in a web page?

 To refer to a CSS file in a web page, you use the <link> element inside the <head> section of the HTML document. Here's t...