Neste artigo, aprendemos como criar o relacionamento entre um documento e os recursos externos usando o elemento <link> . Esta tag é usada para definir um link entre um documento e um recurso externo. A tag de link é usada para vincular a folhas de estilo externas. Este elemento pode aparecer várias vezes, mas vai apenas na seção principal.
O elemento do link está vazio, ele contém apenas atributos.

Sintaxe:

 <link rel="stylesheet" type="text/css" href="styles.css">

Exemplo:

<!DOCTYPE html> 
<html> 
  
<head> 
    <title>Define the relationship between a 
        document and the external resources
</title> 
    <link rel="stylesheet"
        type="text/css"
        href="styles.css"> 
</head> 
  
<body> 
  
    <h1>GeeksforGeeks</h1> 
    <h2>HTML5: How to define the relationship 
between a document and the external resources?
</h2> 
  
</body> 
  
</html> 

Código CSS:

h1 {
    color: green;
}
  
h1, h2{
    text-align: center;
}

Saída:

Navegadores Suportados:

  • Google Chrome
  • Internet Explorer
  • Raposa de fogo
  • Ópera
  • Safári