Html attribute: rel


The HTML element specifies relationships between the current document & an external resource. This element is most commonly used khổng lồ liên kết lớn stylesheets, but is also used to lớn establish site icons (both "favicon" style icons và icons for the home screen và apps on Mobile devices) aý muốn other things.

Bạn đang xem: Html attribute: rel

This simple example provides the path lớn the stylesheet inside an href attribute, và a rel attribute with a value of stylesheet. The rel stands for "relationship", and is probably one of the key features of the element — the value denotes how the thành tựu being linked khổng lồ is related to lớn the containing document. As you"ll see from our Link types reference, there are many different kinds of relationship.

There are a number of other comtháng types you"ll come across. For example, a link khổng lồ the site"s favicon:

There are a number of other inhỏ rel values, mainly used lớn indicate special inhỏ types for use on various di động platforms, e.g.:

The sizes attribute indicates the ibé form size, while the type contains the MIME type of the resource being linked. These provide useful hints khổng lồ allow the browser khổng lồ choose the most appropriate inhỏ available.

Xem thêm: Bộ 7 Template Mẫu Digital Marketing Plan Và Kế Hoạch Digital Marketing Mẫu

You can also provide a media type or query inside a media attribute; this resource will then only be loaded if the media condition is true. For example:

link href="print.css" rel="stylesheet" media="print">liên kết href="thiết bị di động.css" rel="stylesheet" media="screen & (max-width: 600px)">
Some interesting new performance & security features have sầu been added to lớn the element too. Take this example:

A rel value of preload indicates that the browser should preload this resource (see Preloading nội dung with rel="preload" for more details), with the as attribute indicating the specific class of nội dung being fetched. The crossorigin attribute indicates whether the resource should be fetched with a CORS request.

Other usage notes:

A element can occur either in the or element, depending on whether it has a liên kết type that is body-ok. For example, the stylesheet link type is body-ok, và therefore is permitted in the body. However, this isn"t a good practice lớn follow; it makes more sense to separate your elements from your toàn thân content, putting them in the . When using The HTML và XHTML specifications define event handlers for the element, but it is unclear how they would be used. Under XHTML 1.0, empty elements such as require a trailing slash: . WebTV supports the use of the value next for rel lớn preload the next page in a document series.

This element includes the global attributes.

This attribute is only used when rel="preload" or rel="prefetch" has been mix on the element. It specifies the type of nội dung being loaded by the , which is necessary for request matching, application of correct content security policy, and setting of correct Accept request header. Furthermore, rel="preload" uses this as a signal for request prioritization. The table below lists the valid values for this attribute and the elements or resources they apply to lớn. Value Applies To audio elements document & elements embed elements fetch

fetch, XHR

font-face image & elements with srcphối or imagephối attributes, SVG elements, CSS *-image rules object elements script