HTML <a> href 속성

❮ HTML <a> 태그

예시

href 속성은 링크의 목적지를 지정합니다:

<a href="https://www.w3schools.com">Visit W3Schools</a>

아래에서 더 많은 "직접 사용해 보기" 예를 살펴보세요.


정의 및 사용

href속성은 링크가 이동하는 페이지의 URL을 지정합니다 .

href속성이 없으면 태그 <a>는 하이퍼링크가 아닙니다.

팁: href="#top" 또는 를 사용 href="#" 하여 현재 페이지 상단에 연결할 수 있습니다!


브라우저 지원

Attribute
href Yes Yes Yes Yes Yes

통사론

<a href="URL">

속성 값

Value Description
URL The URL of the link.

Possible values:

  • An absolute URL - points to another web site (like href="http://www.example.com/default.htm")
  • A relative URL - points to a file within a web site (like href="default.htm")
  • Link to an element with a specified id within the page (like href="#section2")
  • Other protocols (like https://, ftp://, mailto:, file:, etc..)
  • A script (like href="javascript:alert('Hello');")


더 많은 예

예시

이미지를 링크로 사용하는 방법:

<a href="https://www.w3schools.com">
<img border="0" alt="W3Schools" src="logo_w3s.gif" width="100" height="100">
</a>

예시

이메일 주소에 연결하는 방법:

<a href="mailto:[email protected]">Send email</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 <a> 태그