HTML <a> 태그
예시
W3Schools.com에 대한 링크 만들기:
<a href="https://www.w3schools.com">Visit W3Schools.com!</a>
아래에서 더 많은 "직접 사용해 보기" 예를 살펴보세요.
정의 및 사용
태그 는 <a>
한 페이지에서 다른 페이지로 연결하는 데 사용되는 하이퍼링크를 정의합니다.
<a>
요소 의 가장 중요한 속성은
href
링크의 목적지를 나타내는 속성입니다.
기본적으로 링크는 모든 브라우저에서 다음과 같이 표시됩니다.
- 방문하지 않은 링크는 밑줄과 파란색
- 방문한 링크는 밑줄과 보라색
- 활성 링크는 밑줄과 빨간색으로 표시됩니다.
팁 및 참고 사항
팁:<a>
태그에 속성이 없으면 하이퍼
href
링크에 대한 자리 표시자일 뿐입니다.
팁: 다른 대상을 지정하지 않는 한 연결된 페이지는 일반적으로 현재 브라우저 창에 표시됩니다.
팁: CSS를 사용하여 링크 스타일 지정: CSS 링크 및 CSS 버튼 .
브라우저 지원
Element | |||||
---|---|---|---|---|---|
<a> | Yes | Yes | Yes | Yes | Yes |
속성
Attribute | Value | Description |
---|---|---|
download | filename | Specifies that the target will be downloaded when a user clicks on the hyperlink |
href | URL | Specifies the URL of the page the link goes to |
hreflang | language_code | Specifies the language of the linked document |
media | media_query | Specifies what media/device the linked document is optimized for |
ping | list_of_URLs | Specifies a space-separated list of URLs to which, when the link is followed, post requests with the body ping will be sent by the browser (in the background). Typically used for tracking. |
referrerpolicy | no-referrer no-referrer-when-downgrade origin origin-when-cross-origin same-origin strict-origin-when-cross-origin unsafe-url |
Specifies which referrer information to send with the link |
rel | alternate author bookmark external help license next nofollow noreferrer noopener prev search tag |
Specifies the relationship between the current document and the linked document |
target | _blank _parent _self _top |
Specifies where to open the linked document |
type | media_type | Specifies the media type of the linked document |
전역 속성
<a>
태그는 HTML의 전역 속성도 지원 합니다 .
이벤트 속성
<a>
태그는 HTML의 이벤트 속성 도 지원합니다 .
더 많은 예
예시
이미지를 링크로 사용하는 방법:
<a href="https://www.w3schools.com">
<img border="0" alt="W3Schools"
src="logo_w3s.gif" width="100" height="100">
</a>
예시
새 브라우저 창에서 링크를 여는 방법:
<a href="https://www.w3schools.com" target="_blank">Visit W3Schools.com!</a>
예시
전화번호에 연결하는 방법:
<a href="tel:+4733378901">+47 333 78 901</a>
예시
같은 페이지의 다른 섹션으로 연결하는 방법:
<a href="#section2">Go to Section 2</a>
예시
JavaScript에 연결하는 방법:
<a href="javascript:alert('Hello World!');">Execute JavaScript</a>
관련 페이지
HTML 튜토리얼: HTML 링크
HTML DOM 참조: 앵커 개체
CSS 튜토리얼: 링크 스타일 지정
기본 CSS 설정
대부분의 브라우저는 <a>
다음 기본값으로 요소를 표시합니다.
a:link, a:visited {
color: (internal value);
text-decoration: underline;
cursor: auto;
}
a:link:active, a:visited:active {
color: (internal value);
}