html <link> 标签定义文档与外部资源的关系
link 元素是空元素,它仅包含属性
此元素只能存在于 head 部分,不过它可出现任何次数
属性
属性 | 值 | 描述 |
---|---|---|
charset | char_encoding | html5 不支持该属性 定义被链接文档的字符编码方式 |
href | URL | 定义被链接文档的位置 |
hreflang | language_code | 定义被链接文档中文本的语言 |
media | media_query | 设置被链接文档将显示在什么设备上 |
rel | alternate archives author bookmark external first help icon last license next nofollow noreferrer pingback prefetch prev search sidebar stylesheet tag up |
必需。定义当前文档与被链接文档之间的关系 |
rev | reversed relationship | HTML5 不支持该属性。定义被链接文档与当前文档之间的关系 |
sizes | HeightxWidthany | 定义了链接属性大小,只对属性 rel="icon" 起作用 |
target | _blank _self _top _parent frame_name |
HTML5 不支持该属性 定义在何处加载被链接文档 |
type | MIME_type | 设置被链接文档的 MIME 类型 |
范例
<head> <link rel="stylesheet" href="/static/media/html/styles.css">
HTML 4.01 与 HTML5 之间的差异
HTML5 新增了 "sizes" 属性