Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

<link>

현재 번역은 완벽하지 않습니다. 한국어로 문서 번역에 동참해주세요.

개요

HTML Link 요소 (<link>) 는 현재 문서와 외부 리소스와의 관계를 명시합니다. 이 요소는 네비게이션을 위한 관계형 프레임워크의 정의에도 사용될 수 있습니다. 이 요소는 스타일 시트에 링크하는 데에 가장 많이 사용됩니다.

속성

이 요소는 전역 속성을 포함합니다

charset
이 속성은 링크된 리소스의 문자 인코딩을 정의합니다.. 값은 RFC 2045에 정의된 -와 /와 ,(쉼표)로 구분되는 문자 공간의 목록입니다. 기본 값은 ISO-8859-1 입니다.
사용시 참고: 이 속성은 HTML5에서 폐기(obsolete)되었으며 작성자에 의해서 사용되어서는 안됩니다. 이 효과를 달성하기 위해서는 링크된 리소스에 Content-Type HTTP 헤더를 사용하세요.
crossorigin HTML5
이 열거된 속성은 관련된 이미지의 fetching이 CORS를 통해 수행되어야 하는지 말아야하는지를 가리킵니다. CORS-enabled images<canvas> 요소에서 더럽힘 없이 재사용 되어질수 있습니다. 허락되는 값들은:
anonymous
cross-origin 요청(i.e. with Origin: HTTP header)이 수행됩니다. 하지만 어떤 자격증명서도 전송되지 않습니다. (i.e. no cookie, no X.509 certificate and no HTTP Basic authentication is sent). If the server does not give credentials to the origin site (by not setting the Access-Control-Allow-Origin: HTTP header), the image will be tainted and its usage restricted..
use-credentials
A cross-origin request (i.e. with Origin: HTTP header) is performed with credential is sent (i.e. a cookie, a certificate and HTTP Basic authentication is performed). If the server does not give credentials to the origin site (through Access-Control-Allow-Credentials: HTTP header), the image will be tainted and its usage restricted.
When not present, the resource is fetched without a CORS request (i.e. without sending the Origin: HTTP header), preventing its non-tainted used in <canvas> elements. If invalid, it is handled as if the enumerated keyword anonymous was used. See CORS settings attributes for additional information.
disabled
This attribute is used to disable a link relationship. In conjunction with scripting, this attribute could be used to turn on and off various style sheet relationships.

참고: While there is no disabled attribute in the HTML standard, there is a disabled attribute on the HTMLLinkElement DOM object.

The use of disabled as an HTML attribute is non-standard and only used by some browsers (W3 #27677). Do not use it. To achieve a similar effect, use one of the following techniques:

  • If the disabled attribute has been added directly to the element on the page, do not include the <link> element instead;
  • Set the disabled property of the StyleSheet DOM object via scripting.
href
이 속성은 링크된 리소스의 URL을 나타냅니다. URL은 절대적이거나 상대적입니다. \
hreflang
이 속성은 링크된 리소스의 언어를 나타냅니다. 이것은 순수히 조언입니다. 사용할수 있는 값은 HTML5에서는 BCP47, HTML 4에서는 RFC1766입니다. 이 속성은 href 속성이 존재할때만 사용하세요
media
This attribute specifies the media which the linked resource applies to. Its value must be a media query. This attribute is mainly useful when linking to external stylesheets by allowing the user agent to pick the best adapted one for the device it runs on.
사용 참고:
  • In HTML 4, this can only be a simple white-space-separated list of media description literals, i.e., media types and groups, where defined and allowed as values for this attribute, such as print, screen, aural, braille. HTML5 extended this to any kind of media queries, which are a superset of the allowed values of HTML 4.
  • Browsers not supporting the CSS3 Media Queries won't necessarily recognize the adequate link; do not forget to set fallback links, the restricted set of media queries defined in HTML 4.
methods
The value of this attribute provides information about the functions that might be performed on an object. The values generally are given by the HTTP protocol when it is used, but it might (for similar reasons as for the title attribute) be useful to include advisory information in advance in the link. For example, the browser might choose a different rendering of a link as a function of the methods specified; something that is searchable might get a different icon, or an outside link might render with an indication of leaving the current site. This attribute is not well understood nor supported, even by the defining browser, Internet Explorer 4. See Methods Property (MSDN).
rel
이 속성은 링크된 문서와 현재 문서와의 관계를 명명합니다. 값은 공백으로 구분된 일련의  l링크 타입 값이여야 합니다. 이 속성의 가장 일반적인 쓰임새는 스타일시트의 링크를 나타내는것입니다: rel 속성으로 스타일시트로 설정하고, href 속성으로 외부 스타일 시트의 URL을 지정합니다. WebTV also supports the use of the value next for rel to preload the next page in a document series.
rev
The value of this attribute shows the relationship of the current document to the linked document, as defined by the href attribute. The attribute thus defines the reverse relationship compared to the value of the rel attribute. Link types values for the attribute are similar to the possible values for rel.
사용 참고: 이 속성은 HTML5에서 폐기되었습니다.. 이 속성을 사용하지 마세요. To achieve its effect, use the rel attribute with the opposite link types values, e.g. made should be replaced by author. Also this attribute doesn't mean revision and must not be used with a version number, which is unfortunately the case on numerous sites.
sizes HTML5
This attribute defines the sizes of the icons for visual media contained in the resource. It must be present only if the rel contains the icon link types value. It may have the following values:
  • any, meaning that the icon can be scaled to any size as it is in a vectorial format, like image/svg+xml.
  • a white-space separated list of sizes, each in the format <width in pixels>x<height in pixels> or <width in pixels>X<height in pixels>. Each of these sizes must be contained in the resource.
사용 참고:
  • Most icon format are only able to store one single icon; therefore most of the time the sizes contains only one entry. Among the major browsers, only the Apple's ICNS format allows the storage of multiple icons, and this format is only supported in WebKit.
  • Apple's iOS does not support this attribute, hence Apple's iPhone and iPad use special, non-standard link types values to define icon to be used as Web Clip or start-up placeholder: apple-touch-icon and apple-touch-startup-icon.
target
Defines the frame or window name that has the defined linking relationship or that will show the rendering of any linked resource.
type
이 속성은 링크된 콘텐츠의 타입을 정의하는데 사용됩니다. 속성의 값은 text/html, text/css와 같은 MIME 타입이여야합니다. 이 속성은 링크된 스타일시트의 타입을 지정하는데 쓰이는것이 보통이며, text/css 값이 가장 흔합니다.

예제

스타일 시트 포함하기

페이지에 스타일 시트를 포함하려면, 밑의 문법을 사용하세요

<link href="style.css" rel="stylesheet">

대체 스타일시트 제공하기

당신은 대체 스타일시트를 제공할수도 있습니다.

유저는 View>Page Style 메뉴에서 사용할 스타일시트를 고를수 있습니다. 이것은 유저가 페이지를 여러 버전으로 볼수 있는 방법을 제공합니다.

<link href="default.css" rel="stylesheet" title="Default Style">
<link href="fancy.css" rel="alternate stylesheet" title="Fancy">
<link href="basic.css" rel="alternate stylesheet" title="Basic">

스타일시트 load 이벤트

당신은 load 이벤트를 통해 스타일시트가 언제 로드되는지 확인할수 있습니다. 비슷한 방법으로, 당신은 error 이벤트를 통해 스타일시트를 처리하는 도중 에러가 발생했는지 확인할 수 있습니다:

<script>
function sheetLoaded() {
  // Do something interesting; the sheet has been loaded
}

function sheetError() {
  alert("An error occurred loading the stylesheet!");
}
</script>

<link rel="stylesheet" href="mystylesheet.css" onload="sheetLoaded()" onerror="sheetError()">
참고: The load event fires once the stylesheet and all of its imported content has been loaded and parsed, and immediately before the styles start being applied to the content.

참고

  • <link>태그는 <head>요소 내에서만 등장할수 있습니다; 하지만, there 여러개의 <link> 가 등장할수도 있습니다.
  • HTML 3.2는 link 요소의  href, rel, rev, title 속성만을 정의합니다.
  • HTML 2는 link 요소의 href, methods, rel, rev, titleurn 속성을 정의합니다. methodsurn 속성은 후에 사양에서 제거됍니다.
  • HTML과 XHTML 사양은 <link> 요소를 위한 이벤트 핸들러를 정의했지만 그것들이 어떻게 사용될지는 불분명합니다.
  • Under XHTML 1.0, empty elements such as <link> require a trailing slash: <link />.

사양

사양 상태 주석
WHATWG HTML Living Standard
The definition of '<link>' in that specification.
Living Standard  
HTML5
The definition of '<link>' in that specification.
Recommendation  
HTML 4.01 Specification
The definition of '<link>' in that specification.
Recommendation  

브라우저 호환성

기능 Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 1.0 (1.7 or earlier) (Yes) (Yes) (Yes)
대체 스타일시트 ? 3.0 (1.9) ? (Yes) ?
disabled 속성 Not supported Not supported (Yes) Not supported Not supported
methods 속성 Not supported Not supported 4.0 Not supported Not supported
sizes 속성 Not supported Not supported bug 441770 Not supported Not supported Not supported
load and error 이벤트

19 (Webkit: 535.23)

(WebKit bug 38995)

9.0 (9.0) ? 11.60 ?
crossorigin 속성 25 18.0 (18.0) ? 15 ?
기능 Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic Support (Yes) 1.0 (1.0) (Yes) (Yes) (Yes)
대체 스타일시트 ? 4.0 (2.0) ? ? ?
disabled 속성 Not supported Not supported ? Not supported Not supported
methods 속성 Not supported Not supported 4.0 Not supported Not supported
sizes 속성 Not supported Not supported bug 441770 Not supported Not supported Not supported
load and error 이벤트 ? 9.0 (9.0) ? ? ?
crossorigin ? 18.0 (18.0) ? ? ?

같이 보기

문서 태그 및 공헌자

 이 페이지의 공헌자: azunyan3
 최종 변경: azunyan3,