IT/HTML

1.6 HTML5 Tag - Link

프티 2021. 3. 30. 14:54
반응형

Hyper : 정보가 다중으로 연결되어 있는 상태

Hyper link : 한 텍스트에서 다른 텍스트로 건너뛰어 읽을 수 있는 기능

 

HTML Link = hyperlink

 

a(anchor) tag가 그 역할을 담당한다.

<!DOCTYPE html>
<html>
  <body>
    <a href="http://www.google.com">Visit google.com!</a>
  </body>
</html>

1. href 어트리뷰트

href 어트리뷰트는 이동하고자 하는 파일의 위치를 값으로 받는다.

  1.1 디렉터리(폴더)

  루트 디렉터리 (파일 시스템 계층 구조 상의 최상위 디렉터리)

  •   Unix : /
  •   Window : C:\

  홈 디렉터리 (시스템 사용자에게 할당된 개별 디렉터리)

  •   Unix : /Users/[계정명]
  •   Window : C:\Users\[계정명]

  작업 디렉터리 (작업 중인 파일에 위치한 디렉터리)

  •   ./

  부모 디렉터리 (작업 디렉터리의 부모 디렉터리)

  •   ../

  1.2 파일 경로 (File path)

  절대 경로 (루트 디렉터리 기준)

  • http://www.mysite.com/index.html
  • /Users/leeungmo/Desktop/myImage.jpg
  • C:\users\leeungmo\Desktop\myImage.jpg
  • /index.html

  상대 경로 (현재 작업 디렉터리를 기준)

  • ./index.html
  • ../dist/index.js
  • ../../dist/index.js
  • index.html
  • html/index.htm

 

  href 어트리뷰트에 사용 가능한 값

절대 URL

웹사이트 URL (href="http://www.example.com/default.html")

상대 URL

자신의 위치를 기준으로한 대상의 URL

(href="html/default.html")

fragment identifier

페이지 내의 특정 id를 갖는 요소에 링크 (href="#top")

메일

mailto:

script

href="javascript:alert('Hello');"

fragment identifier 사용 예시

<!DOCTYPE html>
<html>
<body>

<h2 id="top">Top of page!</h2>

<p>In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.</p>
<p>"Whenever you feel like criticizing any one," he told me, "just remember that all the people in this world haven't had the advantages that you've had."</p>
<p>He didn't say any more, but we've always been unusually communicative in a reserved way, and I understood that he meant a great deal more than that. In consequence, I'm inclined to reserve all judgments, a habit that has opened up many curious natures to me and also made me the victim of not a few veteran bores. The abnormal mind is quick to detect and attach itself to this quality when it appears in a normal person, and so it came about that in college I was unjustly accused of being a politician, because I was privy to the secret griefs of wild, unknown men. Most of the confidences were unsought-frequently I have feigned sleep, preoccupation, or a hostile levity when I realized by some unmistakable sign that an intimate revelation was quivering on the horizon; for the intimate revelations of young men, or at least the terms in which they express them, are usually plagiaristic and marred by obvious suppressions. Reserving judgments is a matter of infinite hope. I am still a little afraid of missing something if I forget that, as my father snobbishly suggested, and I snobbishly repeat, a sense of the fundamental decencies is parcelled out unequally at birth.</p>
<p>And, after boasting this way of my tolerance, I come to the admission that it has a limit. Conduct may be founded on the hard rock or the wet marshes, but after a certain point I don't care what it's founded on. When I came back from the East last autumn I felt that I wanted the world to be in uniform and at a sort of moral attention forever; I wanted no more riotous excursions with privileged glimpses into the human heart. Only Gatsby, the man who gives his name to this book, was exempt from my reaction-Gatsby, who represented everything for which I have an unaffected scorn. If personality is an unbroken series of successful gestures, then there was something gorgeous about him, some heightened sensitivity to the promises of life, as if he were related to one of those intricate machines that register earthquakes ten thousand miles away. This responsiveness had nothing to do with that flabby impressionability which is dignified under the name of the "creative temperament"-it was an extraordinary gift for hope, a romantic readiness such as I have never found in any other person and which it is not likely I shall ever find again. No-Gatsby turned out all right at the end; it is what preyed on Gatsby, what foul dust floated in the wake of his dreams that temporarily closed out my interest in the abortive sorrows and short-winded elations of men.</p>

<a href="#top">Go to top</a>
</body>
</html>

태그에 id 값을 넣고 href="#id이름"을 사용하여 해당 위치로 화면을 움직이게 한다.

 

 

 

 

 

 

 

출처 : poiemaweb.com/

반응형

'IT > HTML' 카테고리의 다른 글

1.8 HTML5 Tag - Image & Multimedia  (0) 2021.03.31
1.7 HTML5 Tag - List & Table  (0) 2021.03.30
1.5 HTML5 Tag - Text  (0) 2021.03.29
1.4 HTML5 Tag - Basic  (0) 2021.03.28
1.3 Semantic Web  (0) 2021.03.26