English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML 参考手册

HTML 标签大全

HTML link href 属性

href属性指定外部资源(通常是样式表文件)的位置(URL)。

 HTML <link> etiqueta

在线示例

链接到外部样式表:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <link> <href> 属性使用-教程(oldtoolbag.com)</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>I am formatted with a linked style sheet</h1>
<p>Me too!</p>
</body>
</html>
Prueba aquí ‹/›

Compatibilidad del navegador

IEFirefoxOperaChromeSafari

Todos los navegadores principales admiten la propiedad href.

Definición y uso

La propiedad href especifica la ubicación del recurso externo (generalmente archivos de hojas de estilo) (URL).

HTML 4.01 y HTML5Diferencias entre

Ninguna.

Sintaxis

<link href="URL">

Valor del atributo

ValorDescripción
URLRecurso enlazado/URL del documento.

Valores posibles:

  • URL absoluta - apunta a otro sitio web (por ejemplo href="http://www.example.com/theme.css")

  • URL relativa - apunta a un archivo dentro del sitio web (por ejemplo href="/temas/theme.css")

 HTML <link> etiqueta