Link tag_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:47:53
Original
1190 people have browsed it

link overview

Element definition

The link element in HTML defines the relationship between the current document and external resources. This element is often used to link a style sheet to implement reference styles. surface. The link element can only exist in the head section and can appear multiple times. As shown below, we define a connected external style sheet theme.css to format the HTML document through the style definitions of the style sheet.
Listing 1. Link element application example


Element attributes

Public attributes:
First of all, the link element is an HTML element, therefore, link There are some common attributes of elements in HTML, such as id, class, title, style, dir, lang, xml:lang.
Optional attributes:
In addition, in the HTML4 standard, some specific optional attributes are defined for the link element, as shown in Table 1 below.

Table 1. HTML4 standard attributes

属性 值 描述
charset charset 定义被链接文档的字符编码方式
href URL 定义被链接文档的地址 URI
hreflang language_code 定义被链接文档中文本的语言
media Screen, tty, tv, projection, handheld, print, braille, aural, all 规定被链接文档将显示在什么设备上
rel Alternate, appendix, bookmark, chapter, contents, copyright, glossary, help, home, index, next, prev, section, start, stylesheet, subsection 定义当前文档与被链接文档之间的关系。如 alternate 定义交替出现的链接;appendix 定义文档的附加信息;bookmark 定义书签;copyright 定义当前文档的版权。
rev Alternate, appendix, bookmark, chapter, contents, copyright, glossary, help, home, index, next, prev, section, start, stylesheet, subsection 定义被链接文档与当前文档之间的关系,rev 与 rel 属性互补,rel 指定了向前链接的关系,rev 指定了反向链接的关系。
type MIME_type 定义被链接文档的 MIME 类型,如 text/html, text/css

In the new HTML5 standard, there are some changes to the above attributes. First, some attributes in the original HTML4 are deleted, such as charset and rev. These two attributes will no longer be supported in HTML5; secondly, new attributes sizes and crossorign have been added. The specific information is shown in Table 2 below.

Table 2. HTML5 standard new attributes

属性 值 描述
sizes heightxwidth,any 规定被链接资源的尺寸。仅适用于 rel="icon"。
crossorigin Anonymous,use-credentials 规定是否使用 CORS(CrossOrigin Resources Sharing)跨源资源共享,获取相关图像。

Other attributes:

Such as disabled and target attributes, where the disabled attribute is used to disable a link, which is disabled The styles contained in the link element file cannot be applied to HTML elements. The Target property defines the window or frame in which the connected document is loaded.
The above two attributes do not belong to the strict W3C standards. They are browser-related definitions and are not widely supported and applied. Among them, disabled is a custom attribute of IE browser, which is supported starting from IE5.5 version. Other browsers also have varying degrees of support for this attribute. Below, we will discuss the compatibility of the disabled attribute of the link element in different browsers.

Related references:

Detailed explanation of the disable attribute of the Link element in HTML

jQuery’s attr and prop (the difference between Attribute and Property)

Introduction of css external style sheet (Relative path and absolute path)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template