Linking an external CSS stylesheet to HTML

I am new to HTML / CSS and want one of my HTML files to use a CSS file. How can i do this?

+3
source share
3 answers

You can specify external style sheets with the following LINK element attributes:

  • Set the href value to the location of the stylesheet file. The href value is a URL.

  • Set the value of the type attribute to indicate the language of the associated (style sheet) resource. This allows the user agent to avoid loading the style sheet for an unsupported style sheet language.

  • Indicate that the style sheet is persistent, preferred, or alternative:
  •   
  • , rel "stylesheet" title.  
  • , rel "stylesheet" title.  
  • , rel "alternate stylesheet" title.  

, mystyle.css:

<LINK href="path_to_css_file" rel="stylesheet" type="text/css">
+2

<head> HTML , :

<link rel="stylesheet" type="text/css" href="/path/to/your/style.css" />
+7
+6

Source: https://habr.com/ru/post/1727019/


All Articles