Front-End/HTML

[HTML] 05. Hyperlink

Bigone17 2021. 11. 15. 16:38

๐ŸŸก 1. hyperlink

 - hyperlink๋Š” html link๋ผ๊ณ ๋„ ๋ถˆ๋ฆฌ๊ณ , hyperlink๋ฅผ ๋ˆŒ๋ €์„ ์‹œ ์ž‘์„ฑ์ž๊ฐ€ ์„ค๋ช…ํ•˜๊ณ ์ž ํ•˜๋Š” ๋‚ด์šฉ์ด ์žˆ๋Š” ์›น์ฃผ์†Œ๋กœ ์ด๋™ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ํƒœ๊ทธ๋กœ๋Š” a ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>HTML hyperlink</title>
  </head>
  <body>
    <a href="https://www.naver.com">๋„ค์ด๋ฒ„ ํ™ˆํŽ˜์ด์ง€ ๊ณ ๊ณ </a>
  </body>
</html>

๋„ค์ด๋ฒ„ ํ™ˆํŽ˜์ด์ง€ ๊ณ ๊ณ 

 

๐ŸŸก 1.1 href ์†์„ฑ(attribute)

 - href ์†์„ฑ์€ ์ด๋™ํ•˜๊ณ ์ž ํ•˜๋Š” ์ •๋ณด๋‚˜ ํŒŒ์ผ์˜ ์œ„์น˜(๊ฒฝ๋กœ)๋ฅผ ์ง€์ •ํ•ด์ค๋‹ˆ๋‹ค. ๊ฒฝ๋กœ๋Š” ์›น์‚ฌ์ดํŠธ์˜ ์ฃผ์†Œ ์ผ ์ˆ˜๋„ ์žˆ๊ณ , ๋‚ด ์ปดํ“จํ„ฐ ์•ˆ์— ํŒŒ์ผ ๊ฒฝ๋กœ ์ผ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๐ŸŸก 1.1.1 ๋””๋ ‰ํ† ๋ฆฌ(Directory)

 - ๋””๋ ‰ํ† ๋ฆฌ๋Š” ์ปดํ“จํŒ…์—์„œ ํŒŒ์ผ์„ ๋ถ„๋ฅ˜ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ์ด๋ฆ„ ๊ณต๊ฐ„์ด๋ผ๊ณ  ์œ„ํ‚ค๋ฐฑ๊ณผ์—์„œ๋Š” ์„ค๋ช…ํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์‰ฝ๊ฒŒ ๋งํ•ด์„œ ํด๋”๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์กฐ๊ธˆ TMI๋ฅผ ํ•˜์ž๋ฉด MS-DOS, UNIX์™€ ๊ฐ™์€ CLI ํ™˜๊ฒฝ์—์„œ๋Š” ๋””๋ ‰ํ† ๋ฆฌ๋ผ๊ณ  ํ‘œํ˜„ํ•˜๊ณ , ์œˆ๋„์šฐ, OS์™€ ๊ฐ™์€ GUI ํ™˜๊ฒฝ์—์„œ๋Š” ํด๋”๋ผ๊ณ  ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค.

 

  ์„ค๋ช… ๋ช…๋ น๋ฌธ
๋ฃจํŠธ ๋””๋ ‰ํ† ๋ฆฌ ํŒŒ์ผ ์‹œ์Šคํ…œ ๊ณ„์ธต ๊ตฌ์กฐ ์ƒ์˜ ์ตœ์ƒ์œ„ ๋””๋ ‰ํ† ๋ฆฌ - Unix : /
- Windows : C:\
ํ™ˆ ๋””๋ ‰ํ† ๋ฆฌ ์‹œ์Šคํ…œ์˜ ์‚ฌ์šฉ์ž์—๊ฒŒ ํ• ๋‹น๋œ ๊ฐœ๋ณ„ ๋””๋ ‰ํ† ๋ฆฌ - Unix : /Users/{์‚ฌ์šฉ์ž๋ช…}
- Windows : C:\Users\{์‚ฌ์šฉ์ž๋ช…}
์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ ์ž‘์—…์ค‘์ธ ํŒŒ์ผ์˜ ์œ„์น˜ํ•œ ๋””๋ ‰ํ† ๋ฆฌ ./
๋ถ€๋ชจ ๋””๋ ‰ํ† ๋ฆฌ ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ์˜ ๋ถ€๋ชจ ๋””๋ ‰ํ† ๋ฆฌ ../

 

 

๐ŸŸก 1.1.2 ํŒŒ์ผ ๊ฒฝ๋กœ (File Path)

 - ํŒŒ์ผ ๊ฒฝ๋กœ๋Š” ํŒŒ์ผ ์‹œ์Šคํ…œ์—์„œ ํŒŒ์ผ์˜ ์œ„์น˜๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ๊ฒฝ๋กœ์—๋Š” ์ ˆ๋Œ€๊ฒฝ๋กœ์™€ ์ƒ๋Œ€๊ฒฝ๋กœ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

  ์„ค๋ช… ์˜ˆ์‹œ
์ ˆ๋Œ€๊ฒฝ๋กœ(Absolute path) ํ˜„์žฌ ์ž‘์—…ํ•˜๋Š” ๋””๋ ‰ํ† ๋ฆฌ์™€๋Š” ์ƒ๊ด€์—†์ด ํŠน์ •ํŒŒ์ผ์˜ ์ ˆ๋Œ€ ์œ„์น˜๋ฅผ ๊ฐ€๋ฆฌํ‚ต๋‹ˆ๋‹ค. - https://www.naver.com 
- D:\GIT\Blog\HTML\project01\1.html
์ƒ๋Œ€๊ฒฝ๋กœ(Relative path) ํ˜„์žฌ ์ž‘์—…ํ•˜๋Š” ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํŠน์  ํŒŒ์ผ์˜ ์ƒ๋Œ€์ ์ธ ์œ„์น˜๋ฅผ ๊ฐ€๋ฆฌํ‚ต๋‹ˆ๋‹ค. - ./1.html
- ../js/1.js

 

ํ˜„์žฌ ์ž‘์—…ํ•˜๋Š” ํŒŒ์ผ์ด 1.html์ด๋ผ๊ณ 
๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค.

(1.html์˜ ์ ˆ๋Œ€ ๊ฒฝ๋กœ : D:\GIT\Blog\HTML\project01\1.html)
โšซ 1_1.js ํŒŒ์ผ ๊ฒฝ๋กœ ๊ตฌํ•˜๊ธฐ โšซ 2.css ํŒŒ์ผ ๊ฒฝ๋กœ ๊ตฌํ•˜๊ธฐ
๐ŸŸข ์ ˆ๋Œ€ ๊ฒฝ๋กœ : D:\GIT\Blog\HTML\project01\1_1.js


๐ŸŸฃ ์ƒ๋Œ€ ๊ฒฝ๋กœ : ./1_1.js
๐ŸŸข ์ ˆ๋Œ€ ๊ฒฝ๋กœ : D:\GIT\Blog\HTML\project02\css\2.css


๐ŸŸฃ ์ƒ๋Œ€ ๊ฒฝ๋กœ : ../project02/css/2.css
โšซ 1.js ํŒŒ์ผ ๊ฒฝ๋กœ ๊ตฌํ•˜๊ธฐ โšซ 2.json ํŒŒ์ผ ๊ฒฝ๋กœ ๊ตฌํ•˜๊ธฐ
๐ŸŸข ์ ˆ๋Œ€ ๊ฒฝ๋กœ : D:\GIT\Blog\HTML\project01\js\1.js


๐ŸŸฃ ์ƒ๋Œ€ ๊ฒฝ๋กœ : ./js/1.js
๐ŸŸข ์ ˆ๋Œ€ ๊ฒฝ๋กœ : D:\GIT\Blog\HTML\project02\json\2.json


๐ŸŸฃ ์ƒ๋Œ€ ๊ฒฝ๋กœ : ../project02/json/2.json

TMI : ์‚ฌ์šฉํ•˜๋Š” tool์€ vscode์ด๊ณ , ์‚ฌ์ง„์— ๋‚˜์™€์žˆ๋Š” ์•„์ด์ฝ˜๋“ค์€ Material Icon Theme์ž…๋‹ˆ๋‹ค ใ…Žใ…Ž

 - a ํƒœ๊ทธ์˜ href ์†์„ฑ์—๋Š” ์•„๋ž˜ ํ‘œ์™€ ๊ฐ™์€ ๊ฐ’์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

Value ์„ค๋ช… ์˜ˆ์‹œ
์ ˆ๋Œ€ url ์›น์‚ฌ์ดํŠธ URL ๋ฐ ํŒŒ์ผ ๊ฒฝ๋กœ <a href="https:www.naver.com">
๋„ค์ด๋ฒ„ URL</a>
์ƒ๋Œ€ url ์ž‘์„ฑ์ค‘์ธ ํŒŒ์ผ ์œ„์น˜๋ฅผ ๊ธฐ์ค€์œผ๋กœํ•œ ๋Œ€์ƒ์˜ URL <a href="1_1.js">1_1jsํŒŒ์ผ</a>
fragment identifier

ํŽ˜์ด์ง€ ๋‚ด์˜ ํŠน์ • id๋ฅผ ๊ฐ–๋Š” ์š”์†Œ์˜ ๋งํฌ <a href="#bottom">ํ•˜๋‹จ์œผ๋กœ</a>
๋ฉ”์ผ ๋ฉ”์ผ ๋ณด๋‚ด๊ธฐ <a href="mailto:people@example.com?Subject=Hello Stranger">๋ฉ”์ผ๋ณด๋‚ด๊ธฐ</a>
script ์Šคํฌ๋ฆฝํŠธ ์‹คํ–‰ <a href="javascript:alert('Hi!');">์•Œ๋Ÿฟ๋„์šฐ๊ธฐ</a>
<!DOCTYPE html>
<html>
  <body>
    <a href="https:www.naver.com">๋„ค์ด๋ฒ„ URL</a><br>
    <a href="1_1.js">1_1jsํŒŒ์ผ</a><br>
    <a href="#bottom">ํ•˜๋‹จ์œผ๋กœ</a><br>
    <a href="mailto:people@example.com?Subject=Hello Stranger">๋ฉ”์ผ๋ณด๋‚ด๊ธฐ</a><br>
    <a href="javascript:alert('Hi!');">์•Œ๋Ÿฟ๋„์šฐ๊ธฐ</a>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
    <p>
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </p>
    <p id="bottom">ํ•˜๋‹จ์ž…๋‹ˆ๋‹ค!</p>
  </body>
</html>

์†Œ์Šค ๋ณต๋ถ™ ํ•ด์„œ ์‹คํ–‰ํ•ด๋ณด์„ธ์š”~ :)

 

 

๐ŸŸก 1.2 target ์†์„ฑ

 - a ํƒœ๊ทธ ์•ˆ์— href ์†์„ฑ ์ด์™ธ์— target์ด๋ผ๋Š” ์†์„ฑ์„ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, target ์†์„ฑ์€ a ํƒœ๊ทธ ํด๋ฆญ ์‹œ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์–ด๋–ป๊ฒŒ ์—ด์ง€ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

value ์„ค๋ช…
_self ๋งํฌ๋ฅผ ํด๋ฆญ ์‹œ ํ˜„์žฌ ๋ธŒ๋ผ์šฐ์ €์—์„œ ์˜คํ”ˆ์„ ํ•ฉ๋‹ˆ๋‹ค.(๊ธฐ๋ณธ๊ฐ’)
_blank ๋งํฌ๋ฅผ ํด๋ฆญ ์‹œ ์ƒˆ๋กœ์šด ๋ธŒ๋ผ์šฐ์ €์—์„œ ์˜คํ”ˆ์„ ํ•ฉ๋‹ˆ๋‹ค.
<!DOCTYPE html>
<html>
  <body>
    <a href="https://daily-life-of-bigone.tistory.com/12" target="_self">์ง€๊ธˆ ์ฐฝ์—์„œ ์—ด๊ธฐ</a><br>
    <a href="https://daily-life-of-bigone.tistory.com/12" target="_blank" rel="noopener noreferrer">์ƒˆ๋กœ์šด ์ฐฝ์—์„œ ์—ด๊ธฐ</a>
  </body>
</html>

- _black๋ฅผ ์ด์šฉํ•ด์„œ ์ƒˆ ํƒญ์œผ๋กœ ๋งํฌ๋ฅผ ์˜คํ”ˆํ–ˆ์„ ๋•Œ ํŽธ๋ฆฌํ•จ์€ ์žˆ์ง€๋งŒ ๋ณด์•ˆ์— ์ทจ์•ฝํ•˜์—ฌ Tabnabbing ํ”ผ์‹ฑ ๊ณต๊ฒฉ์„ ๋‹นํ•  ์ˆ˜๋„ ์žˆ์œผ๋ฏ€๋กœ, rel="noopener noreferrer"๋„ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ๊ฑธ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค! ์•„๋ž˜ ์‚ฌ์ดํŠธ๋ฅผ ์ฐธ๊ณ ํ•˜์‹œ๋ฉด ๋” ์ข‹์Šต๋‹ˆ๋‹ค :)
โ—https://tech.lezhin.com/2017/06/12/tabnabbing

 

 

๊ธด ๊ธ€ ์ฝ์–ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค :) 
ํ‹€๋ฆฐ ๋‚ด์šฉ์ด ์žˆ๊ฑฐ๋‚˜, ๋ง๋ถ™์ผ ๋‚ด์šฉ์ด ์žˆ๋‹ค๋ฉด ์–ธ์ œ๋“ ์ง€ ๋Œ“๊ธ€ ๋‹ฌ์•„์ฃผ์„ธ์š”!
์ œ ๊ธ€์ด ์กฐ๊ธˆ์ด๋‚˜๋งˆ ์ฝ์€ ์‹  ๋ถ„๋“ค์—๊ฒŒ ๋„์›€์ด ๋˜๋„๋ก ๋…ธ๋ ฅํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค
๋‹ค์Œ ํŽธ์— ๋ดฌ์š”~

 

728x90
๋ฐ˜์‘ํ˜•