Thẻ <link> HTML
Thí dụ
Liên kết đến một biểu định kiểu bên ngoài:
<head>
<link rel="stylesheet" href="styles.css">
</head>
Định nghĩa và Cách sử dụng
Thẻ <link>
xác định mối quan hệ giữa tài liệu hiện tại và tài nguyên bên ngoài.
Thẻ <link>
thường được sử dụng nhất để liên kết đến các biểu định kiểu bên ngoài hoặc để thêm biểu tượng yêu thích vào trang web của bạn.
Phần <link>
tử là một phần tử trống, nó chỉ chứa các thuộc tính.
Hỗ trợ trình duyệt
Element | |||||
---|---|---|---|---|---|
<link> | Yes | Yes | Yes | Yes | Yes |
Thuộc tính
Attribute | Value | Description |
---|---|---|
crossorigin | anonymous use-credentials |
Specifies how the element handles cross-origin requests |
href | URL | Specifies the location of the linked document |
hreflang | language_code | Specifies the language of the text in the linked document |
media | media_query | Specifies on what device the linked document will be displayed |
referrerpolicy | no-referrer no-referrer-when-downgrade origin origin-when-cross-origin unsafe-url |
Specifies which referrer to use when fetching the resource |
rel | alternate author dns-prefetch help icon license next pingback preconnect prefetch preload prerender prev search stylesheet |
Required. Specifies the relationship between the current document and the linked document |
sizes | HeightxWidth any |
Specifies the size of the linked resource. Only for rel="icon" |
title | Defines a preferred or an alternate stylesheet | |
type | media_type | Specifies the media type of the linked document |
Thuộc tính toàn cầu
Thẻ <link>
cũng hỗ trợ Thuộc tính chung trong HTML .
Thuộc tính sự kiện
Thẻ <link>
cũng hỗ trợ Thuộc tính sự kiện trong HTML .
Các trang liên quan
Hướng dẫn HTML: Kiểu HTML
Tham chiếu DOM HTML: Đối tượng liên kết
Cài đặt CSS mặc định
Hầu hết các trình duyệt sẽ hiển thị <link>
phần tử với các giá trị mặc định sau:
link {
display: none;
}