Webã¯ãªã³ã¯ã®éãŸã
aèŠçŽ ã¯ãã€ããŒãªã³ã¯ïŒä»¥äžãå¿ èŠã«å¿ããŠåçŽã«ãªã³ã¯ãšåŒã³ãŸãïŒãäœæããèŠçŽ ã§ããä»ã®ããŒãžãžé·ç§»ãããã®ããåãããŒãžå ãžé·ç§»ãããã®ïŒèšäºã®åé ã®ç®æ¬¡ãªã©ã«ãã䜿çšãããŠããŸããïŒããŸãããã¡ã€ã«ãããŠã³ããŒããããã®ãªã©ããªã³ã¯ã«ããããŸããããããã¯å šãŠaèŠçŽ ã䜿çšããŠäœæããŸãã
HTMLã®ç±æ¥
HTMLã¯Hyper Text Markup Languageã®ç¥ç§°ã§ãããã®ãã€ããŒããã¹ããšããèšèã«ã€ããŠã§ãããããã€ããŒããšã¯ã©ãããæå³ã§ãããããæ®éã®ããã¹ããšäœãéãã®ã§ããããã
HTMLãçãŸãããã£ããã¯ãã¹ã€ã¹ã®ãšããç 究æã§ã®ç 究è«æã®çŽã¥ãã®ããã§ãããç 究ã«å¿ èŠãªããŒã¿ãåèæç®ã倧éã«éããåæ å ±ãè¡ãæ¥ã§ãããªã³ã¯ãããã°äŸ¿å©ã§ã¯ãªãããšèããããŸããããããŠããªã³ã¯ãæã€ç¹å¥ãªïŒãã€ããŒãªïŒããã¹ãããã€ããŒããã¹ããšåŒã³ããªã³ã¯ã®ããšããã€ããŒãªã³ã¯ãšåŒã¶ããã«ãªããŸããã
ãã€ããŒããã¹ãã¯ãã»ãã®ããã¹ããžã®ãªã³ã¯ãå«ãããã¹ãã§ãããå°èª¬ã®ããã«åäžã§ç·åœ¢ã®æµãã®ãã®ãšã¯å¯Ÿç §çãªãã®ã§ãã
åè : Hypertext (ãã€ããŒããã¹ã) | MDN
ãã€ããŒãªã³ã¯ã¯ãŠã§ãããŒãžãããŒã¿é ç®ããäºãã«æ¥ç¶ããŸãã
åè : Hyperlink (ãã€ããŒãªã³ã¯) | MDN
ã€ãŸãããã€ããŒãªã³ã¯ãããããããããã€ããŒããã¹ãïŒâHTMLïŒã§ãããšèšã£ãŠãéèšã§ã¯ãªãã®ã§ãïŒ
ã€ã³ã¿ãŒãããã¯ç¡æ°ã®ãã€ããŒããã¹ãã®éãŸãã§ããããã®äžã«ãããã€ããŒãªã³ã¯ã«ãã£ãŠçžäºã«æ¥ç¶ãããŠããŸãããããŸã§ã®ããŒãžã§ã¯æåãçŸ åããŠã°ã£ããã§ãããããã€ããŒãªã³ã¯ãçšæããŠããŒãžéã蟿ããããã«ãªãã°ããããWebãµã€ãããããªã£ãŠããŸãã
index.htmlãšabout.htmlãçšæãã
ä»åã¯2ã€ã®HTMLãã¡ã€ã«ïŒindex.html
ãšabout.html
ïŒãçšæããŸãããŸãã¯index.html
ã§ãããååãŸã§ã®ãã®ãæµçšããŠãããã§ãããæ°ããäœã£ãŠãæ§ããŸããã
ç¶ããŠãindex.html
ãšåãéå±€ã«pages
ãšãããã©ã«ããŒãäœæããŠãã ããããããŠãã®äžã«about.html
ãäœæããŸããã€ãŸããäžå³ã®ãããªãã©ã«ããŒæ§æã«ãªããŸãã
aã¿ã°ã§ãªã³ã¯ãäœæãã
ãŸãã¯index.html
ã®äœæããåãæãããŸããããabout.html
ãžã®ãªã³ã¯ãäœæããŠã¿ãŸãã以äžã®éãã«èšè¿°ããŠãã ããã
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ã€ã³ããã¯ã¹ããŒãž</title>
</head>
<body>
<h1>ã€ã³ããã¯ã¹ããŒãž</h1>
<a href="./pages/about.html">ã¢ããŠãããŒãžãžã®ãªã³ã¯ã§ãã</a>
</body>
</html>
WebããŒãžã確èªãããšãã¢ã³ããŒããŒãåŒãããéãæåã®ãªã³ã¯ãäœæãããŠããã¯ãã§ãã
ãªã³ã¯ãã¯ãªãã¯ããŠã¿ãŠãabout.html
ãžã¢ã¯ã»ã¹ã§ãããã確èªããŠãã ããã
èŠäºãããŒãžé·ç§»ã§ããã°ãªã³ã¯ã®äœæãå®äºã§ãããã以äžã®ç»é¢ã®ããã«ããã¡ã€ã«ã«ã¢ã¯ã»ã¹ã§ããªãæšã®ãšã©ãŒã¡ãã»ãŒãžã衚瀺ãããå Žåã¯ã
- ð
href
å±æ§ã®èšè¿°ãééã£ãŠãã - ð
pages
ãšãããã©ã«ããŒåãééã£ãŠãã - ð
about.html
ãšãããã¡ã€ã«åãééã£ãŠãã
ã®ãã¡ã®ã©ãããåå ã ãšæãããŸãã
以äžã®href
å±æ§ã«ã€ããŠã®èª¬æãèªã¿ãªãããééãããªããèŠçŽããŠã¿ãŠãã ããã
hrefå±æ§ã§ãªã³ã¯å ãæå®ãã
ã§ã¯ãæ¹ããŠãªã³ã¯ã®äœææ¹æ³ã解説ããŸãã
ãŸããa
ã¿ã°ã§ãªã³ã¯ãšãããæååãå²ããŸãã
<a>ã¢ããŠãããŒãžãžã®ãªã³ã¯</a>
ãªã³ã¯ãèžãã æã®é·ç§»å
ã¯ãhref
å±æ§ã§æå®ããŸããhref
å±æ§ã«ã¯é·ç§»ããããå
ã®ãã¹ãèšè¿°ããŸãã
<a href="./pages/about.html">ã¢ããŠãããŒãžãžã®ãªã³ã¯</a>
ãã¹ã®èšè¿°ã¯cssãã¡ã€ã«ã®èªã¿èŸŒã¿ã®æã«ããããŸããããããã§èšè¿°ããŠãããã¹ã¯çžå¯Ÿãã¹ãšåŒã°ãããã®ã§ãã
çžå¯Ÿãã¹
çžå¯Ÿãã¹ã¯ãçŸåšã®å°ç¹ããç®çã®å°ç¹ãžã®çµè·¯ãèšè¿°ãããã¹ã§ãããçŸåšã®å°ç¹ããšã¯aèŠçŽ ãæžããŠãããã¡ã€ã«ãã€ãŸãindex.html
ã眮ãããŠãããã©ã«ããŒã§ãã
ãŸãã¯ã«ã¬ã³ããã£ã¬ã¯ããªãè¡šã.
ãå
é ã«ä»ããŸãããããŠãéå±€ãåºåã/
ãä»ããŸãã
å³ãçšããŠäŸã瀺ããŸããäŸãã°ãé·ç§»å
ã®htmlãã¡ã€ã«ãåãéå±€ã«ããã®ã§ããã°ãhref="./sample.html"
ãšèšè¿°ããŸããå³ã§è¡šããšä»¥äžã®ããã«ãªããŸãã
ä»åãç®çã®about.html
ã¯pages
ãã©ã«ããŒã®äžã«æ ŒçŽãããŠããŸããã./pages
ãšããããšã§pages
ãã©ã«ããŒã®äžã«äžããããšãã§ããŸãã
åŸã¯ãpages
ãã©ã«ããŒã«ããããªã³ã¯ãããããã¡ã€ã«åãèšè¿°ããã°çžå¯Ÿãªã³ã¯ã®å®æã§ããåºåãã§ãã/
ãã€ããç®çã®ãã¡ã€ã«ã§ããabout.html
ãèšè¿°ããŸãã
ãŸãšãããšã
- âïž çžå¯Ÿãã¹ã¯ããªã³ã¯ãèšè¿°ããŠãããã¡ã€ã«ãèµ·ç¹ãšãããã¹ã®èšè¿°æ¹åŒ
- âïž çŸåšã®ãã©ã«ããŒïŒã«ã¬ã³ããã£ã¬ã¯ããªïŒã¯
.
ã§è¡šã - âïž
/
ã§ãã¡ã€ã«ããã©ã«ããŒãåºåã
ãšãªããŸãã
ãã¡ããããã£ãšæ·±ãéå±€ãŸã§ã®ãã¹ãèšè¿°ã§ããŸãã以äžã®å³ã¯ãindex.html
ããããã©ã«ããŒïŒHTML&CSS
ïŒããèŠãŠãdir1
ãã©ã«ããŒã®äžã®dir2
ãã©ã«ããŒã®äžã®dir3
ãã©ã«ããŒã®äžã®index.html
ãæå®ããŠããã€ã¡ãŒãžå³ã§ãã
ããæéãããã°ãå®éã«ãã©ã«ããŒããã¡ã€ã«ãäœã£ãŠã¿ãŠæ£ãããªã³ã¯ãäœãããç·Žç¿ããŠã¿ãŠãã ããã
äžã®éå±€ãžã¯..
ã§èŸ¿ã
ç¶ããŠãabout.html
ã«ãindex.html
ãžã®ãªã³ã¯ãäœæããçžäºã«èŸ¿ããããã«ããŸãããã
about.html
ã以äžã®ããã«ç·šéããŸãã
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ã¢ããŠãããŒãž</title>
</head>
<body>
<h1>ã¢ããŠãããŒãž</h1>
<a href="./../index.html">ã€ã³ããã¯ã¹ããŒãžãžã®ãªã³ã¯</a>
</body>
</html>
href
å±æ§ã確èªããŸãããããŸãã¯ã«ã¬ã³ããã£ã¬ã¯ããªãè¡šã./
ããå§ããŸããããŠã芪ãã©ã«ããŒãã©ããã£ãŠè¡šããã§ããã..
ã䜿çšããŸããããã ãã§èŠªãã©ã«ããŒãè¡šãããšãã§ããŸãã
ç§ãã¡ãæ®æ®µäœ¿ã£ãŠãããã©ã«ããŒããã¡ã€ã«ã®ä»çµã¿ã«ãããŠã芪ãã©ã«ããŒã¯äžã€ãããªãããã芪ãã©ã«ããŒã®ååãæ瀺ããå¿
èŠã¯ãããŸããïŒãã®å Žåã®ã«ã¬ã³ããã£ã¬ã¯ããªã«ããã芪ãã©ã«ããŒã¯HTML&CSS
ãã©ã«ããŒã ãã§ãããïŒã芪ãã©ã«ããŒã2å以äžååšãããããªäžçç·ãªãã°ãã©ã®ãã©ã«ããŒãæå®ããããèšè¿°ããå¿
èŠããããŸãããå®éã«ã¯äžã€ãããªããã..
ã®ã¿ã§è¡šãããšãã§ããŸãã
about.html
ãå®æãããã¢ã¯ã»ã¹ããŠåäœã確èªããŠãããŸããããindex.html
ã«ã¯about.html
ãžã®ãªã³ã¯ããããabout.html
ã«ã¯index.html
ããããŸããçžäºã«ãªã³ã¯ããããè¡ãæ¥ãã§ããç¶æ
ã«ãªã£ãŠããã¯ãã§ãã
ã«ã¬ã³ããã£ã¬ã¯ããªã¯çç¥ã§ãã
ã«ã¬ã³ããã£ã¬ã¯ããªã¯.
ã§è¡šããšèª¬æããŸããããå®ã¯ããã¯çç¥å¯èœã§ãã
index.html
ã®ãªã³ã¯ã«ã¯./pages/about.html
ãšããhref
å±æ§ãå®çŸ©ããŸããããæåã®./
ããªãããŠãpages/about.html
ãšããèšè¿°ãå·®ãæ¿ããŠãOKã§ãã
åãããã«ãabout.html
ã®ãªã³ã¯ã./../index.html
ãã../index.html
ã«å·®ãæ¿ããããšãå¯èœã§ãã
ç¥ããç¥ããªãããšããæã§ããã1人ã§æžããŠããåã«ã¯å¥œã¿ã§ãããšæããŸããç§ã¯ãã€ãç¥ãããã«ããŠããŸãããã®ã·ãªãŒãºã§ã¯ãã以éãã«ã¬ã³ããã£ã¬ã¯ããªãè¡šã./
ã¯çç¥ããããã«ããŸãã®ã§ãçæãã ããã
ããŒãžå ãªã³ã¯ã®äœæ
ãããŸã§ã¯å¥ã®HTMLãã¡ã€ã«ãžã®ãªã³ã¯ãäœæããŠããŸããããåãããŒãžå ã®ä»»æã®å Žæãžã®ãªã³ã¯ãäœæããããšãã§ããŸããããã°èšäºãªã©ã§ãããããŸãããããŒãžã®å é ã«ç®æ¬¡ã䞊ãã§ããŠã¯ãªãã¯ãããšãã®æ®µèœãŸã§ã¹ã¯ããŒã«ã§ããããšãã£ããã®ã§ãã
id
å±æ§ãèšè¿°ãã
ããããã¯index.html
ãç·šéããŠãããŸãããªã³ã¯ãäœæããåã«ããŸãã¯ãªã³ã¯å
ãå®çŸ©ããŠãããŸãããªã³ã¯å
ã«ãããèŠçŽ ã«id
å±æ§ãèšè¿°ããIDãä»äžããŸãããã®IDã«åãããªã³ã¯ãäœæããããšã«ãªããŸãã
IDãšãªãå±æ§å€ã¯ä»»æã®æååã§æ§ããŸãããåãããããååãèããŸããããããã§ã¯title
ãšããåèªã«ããŸããã
<body>
<h1 id="title">ã¿ã€ãã«</h1>
</body>
次ã«aèŠçŽ ã§ãªã³ã¯ãäœæããŸããå¥ãã¡ã€ã«ãžã®ãªã³ã¯ã®å Žåã¯href
å±æ§ã«çžå¯Ÿãã¹ãèšè¿°ããŸããããããŒãžå
ãªã³ã¯ã®å Žåã¯é·ç§»å
ã®id
å±æ§ã®å€ã®å
é ã«#
ãä»ãèšè¿°ããŸãã
<body>
<a href="#title">ã¿ã€ãã«ãžã®ãªã³ã¯</a>
<h1 id="title">ã¿ã€ãã«</h1>
</body>
ããã§ãªã³ã¯èªäœã¯å®æã§ããããªã³ã¯ãšãªã³ã¯å èŠçŽ ã®éã«ã¹ããŒã¹ããªãã®ã§ãã¯ãªãã¯ããŠãé·ç§»ããŠããããšãåãããªããšæããŸãã以äžã®ãããªdivèŠçŽ ãè¿œå ããŠã¹ããŒã¹ã確ä¿ããŠãã ããã
<body>
<a href="#title">ã¿ã€ãã«ãžã®ãªã³ã¯</a>
<div style="margin-bottom: 50vh;"></div>
<h1 id="title">ã¿ã€ãã«</h1>
<div style="margin-bottom: 100vh;"></div>
</body>
aèŠçŽ ãã¯ãªãã¯ããŠãh1èŠçŽ ãžé·ç§»ããããšã確èªããŠäžããïŒã¹ã¯ããŒã«ãããããšäžç¬ã§ç§»åããŸãïŒã
åãããŒãžå ã§ã®ãªã³ã¯ã¯ãåè¿°ããããã«ç®æ¬¡ãªã©ã§ãã䜿çšããŸããå®éã«WebããŒãžãäœã段éã§å€çšããŸãã®ã§æ¶ããŠãããŠãã ããã
IDã¯1ããŒãžã«1ã€ã ã
IDãšããã®ã¯èå¥åã®ããšã§ãããããèŠçŽ ãèå¥ãç¹å®ããããã«ä»äžãããã®ã§ããåãããŒãžå ã§åãIDãæã€èŠçŽ ãè€æ°ååšããããšã¯èš±ãããŸããã
index.html
ãå°ãæ¹å€ããŠtitle
IDãæã€èŠçŽ ã2ã€çšæããŠã¿ãŸãã
<body>
<a href="#title">ã¿ã€ãã«ãžã®ãªã³ã¯</a>
<div style="margin-bottom: 50vh;"></div>
<h1 id="title">1ã€ç®ã®ã¿ã€ãã«</h1>
<div style="margin-bottom: 50vh;"></div>
<h1 id="title">2ã€ç®ã®ã¿ã€ãã«</h1>
<div style="margin-bottom: 100vh;"></div>
</body>
ããã§ãªã³ã¯ãã¯ãªãã¯ãããšãæãã1ã€ç®ã®h1èŠçŽ ã«é·ç§»ããŸãããã®åŸäœåºŠãªã³ã¯ãã¯ãªãã¯ããŠã2ã€ãã®h1èŠçŽ ã«é·ç§»ããããšã¯ãªãã§ãããã
å®éã«ã©ã®ãããªæåã«ãªããã¯ãã©ãŠã¶ãŒäŸåã§ãããå°ãªããšãããŒã¯ã¢ããããåŽã®æ³å®éãã®åãã«ãªãããšã¯ãããŸãããid
å±æ§ãèšè¿°ããæã¯ãéè€ããããšããªãããã«ãã確èªããŸãããã
ãªããVSCodeã䜿çšããŠããã°ãäžèšç»åã®ããã«IDãéè€ããŠããããšããããã¢ããã§æããŠãããŸãã
IDã¯éè€ããªãããããããªã³ã¯å
ãšããŠæ©èœããŸããéã«éè€ããŠãããclass
å±æ§ããªã³ã¯å
ã«æå®ããããšã¯ã§ããŸãããè€æ°ãããšã©ãã«é·ç§»ããã°ãããåãããŸãããããã
pèŠçŽ ã®äžã«æžãããšãã§ãã
aèŠçŽ ã¯pèŠçŽ ã®äžã«å ¥ããããšãã§ããŸãããã¹ãã§ãããšããäºã§ããã
äžèšã¯pèŠçŽ ã®äžã«aèŠçŽ ãå ¥ããäŸã§ããpèŠçŽ ã®æç« ã®äžã§aèŠçŽ ã ãããªã³ã¯ã«ãªããŸãã
<p>ã¢ããŠãããŒãžãžã®ãªã³ã¯ã¯<a>ãã¡ã</a>ã§ãã</p>
絶察ãã¹ã£ãŠïŒ
å®ã¯ãã¹ã«ã¯ããã€ãçš®é¡ããããŸããçžå¯Ÿãã¹ãšçµ¶å¯Ÿãã¹ã§ãã
絶察ãã¹ã¯ã«ãŒãã»é ç¹ããç®çã®ãã¡ã€ã«ãžã®çµè·¯ãèšè¿°ãããšãããã®ã§ããããã§åé¡ãªã®ããã«ãŒãã»é ç¹ãšããã®ãã©ããæãã®ããç°å¢ã«ãã£ãŠå€ãããšããäºã§ãã
äŸãã°WebãµãŒããŒäžã§åäœããŠããç°å¢ãªãããµãŒããŒã¢ããªã±ãŒã·ã§ã³ã§èšå®ãããŠããã«ãŒããã£ã¬ã¯ããªãã«ãŒãã«ãªããŸãã
ãŸããä»åã®ããã«HTMLãã¡ã€ã«ãããã«ã¯ãªãã¯ããŠå®è¡ããŠãããªãCãã©ã€ããã«ãŒãã«ãªããŸããä»åäœæããabout.html
ãžã®çµ¶å¯Ÿãã¹ã¯C:/Users/<ãŠãŒã¶ãŒå>/Desktop/workdpace/HTML&CSS/pages/about.html
ãšãããµãã«ãªããŸããããã¯Windowsã§ã®çµ¶å¯Ÿãã¹ã®æžãæ¹ã§ãããMacOSãLinuxOSã ãšæžãæ¹ãå€ãã£ãŠããŸããç°å¢ã«ãã£ãŠå€ãããšããã®ã¯ãã®ããšã§ããã®è¬åº§ã§ã¯çµ¶å¯Ÿãã¹ã®èª¬æã¯è¡ããªãäºå®ã§ãã
ã ãHTMLãCSSã®åŠç¿ã«ãããŠã¯ãããŸã§ã«åŠç¿ããçžå¯Ÿãã¹ã®èãæ¹ãåãã£ãŠããã°ååã§ããå ã ãµãŒããŒã¹ã¯ãªãããæžãããã«ãªã£ãŠããã°çµ¶å¯Ÿãã¹ãå©çšããããã«ãªã£ãŠããŸãã
絶察ãã¹ã«ã€ããŠãã£ãšè©³ããç¥ãããæ¹ã¯äžèšãªã³ã¯ãåãããŠåç §ãã ããã
ãŸãšã
- â aèŠçŽ ã§ãªã³ã¯ãäœæãã
- â
ãªã³ã¯å
ã¯
href
å±æ§ã«èšè¿°ãã - â éåžžãçžå¯Ÿãã¹ã§ãªã³ã¯å ãèšè¿°ãã
- â çžå¯Ÿãã¹ã¯ãçŸåšã®å°ç¹ããç®çã®ãã¡ã€ã«ãžã®çµè·¯ãè¡šããã®
- â
ããŒãžå
ãªã³ã¯ãäœæããã«ã¯
id
å±æ§ãå©çšãã
次åã¯HTMLã®åºæ¬ã®æåŸãšããŠãç»åã衚瀺ãããimgèŠçŽ ãåŠç¿ããŸãã
åè
ãŠã§ãäžã®ãªãœãŒã¹ã®èå¥ | MDN
HTMLã£ãŠäœã â ããç°¡åãªHTMLã®èª¬æ
第12åã€ã³ã¿ãŒãããè¬åº§
絶察ãã¹ã»çžå¯Ÿãã¹ãšã¯ïŒïœãã¹ã®èŠæ¹ã»æžãæ¹
ãHTMLãããŒãžå ãªã³ã¯ã®äœãæ¹ïŒèšäºã®éäžã«é£ã°ãã«ã¯ïŒ
HTMLã§åãã¿ã°ã«è€æ°ã®idå±æ§ãæå®ããããšã¯ã§ããïŒ | Qumeruãã¬ãžã³