W3docs

css · CSS Basics

How can you add an external style sheet in HTML?

Answers

  • <link rel="stylesheet" type="text/css" href="mystyle.css">
  • <style src="mystyle.css" />
  • <stylesheet>mystyle.css</stylesheet >
# Implementing External Style Sheets in HTML External style sheets are a powerful tool in HTML, allowing developers to apply a consistent style across multiple pages on a website. They are saved in .css files and linked to HTML documents, so any changes to the style sheet will automatically be applied to all linked documents. The correct way to add an external style sheet in HTML is by using the `` element, which must be located inside the `` section of an HTML document. Here's the correct syntax: ```html ``` This element has several attributes: - `rel`: Describes the relationship between the HTML document and the linked resource. In this case, "stylesheet" indicates that the linked resource is a style sheet. - `type`: Indicates the MIME type of the linked resource, which is "text/css" for CSS style sheets. - `href`: Specifies the URL of the linked resource. This could be a relative or absolute path, depending on where the .css file is located in relation to the HTML file. Incorrect examples, such as `