속성 (attributes) 을 사용하여 링크와 이미지 추가하기
이 단계에서는 이미지와 하이퍼링크를 추가하여 페이지를 더욱 동적으로 만들 것입니다.
<img>: 이미지 태그는 이미지를 삽입하는 데 사용됩니다. 이것은 자체 종료 태그이며 두 가지 필수 속성이 필요합니다:
src: 이미지 파일의 경로를 지정합니다.
alt: 이미지에 대한 대체 텍스트를 제공하며, 이는 접근성과 이미지를 표시할 수 없을 때 중요합니다.
<a>: 앵커 태그는 하이퍼링크를 만드는 데 사용됩니다. href 속성은 링크가 이동할 URL 을 지정합니다.
먼저 프로필 사진을 추가해 봅시다. 설정 스크립트에서 이미 images/profile.png에 플레이스홀더 이미지를 배치했습니다. <h1> 태그 바로 아래에 <img> 태그를 추가하세요.
다음으로, GitHub 프로필과 같은 외부 사이트로 연결되는 링크를 추가해 봅시다. 이를 새로운 "Find Me Online" 섹션에 배치할 것입니다. 기술 목록 아래에 다음 코드를 추가하세요:
<!-- Add this img tag below the h1 tag -->
<img src="images/profile.png" alt="A placeholder profile picture" />
<!-- Add this new section below the skills list -->
<h2>Find Me Online</h2>
<p>
You can find my work on
<a href="https://github.com/labex-labs" target="_blank">GitHub</a>.
</p>
링크의 target="_blank" 속성은 브라우저가 새 탭에서 링크를 열도록 지시합니다.
이제 index.html 파일의 <body>는 다음과 같이 구성되어야 합니다:
<body>
<div class="container">
<h1>John Doe</h1>
<img src="images/profile.png" alt="A placeholder profile picture" />
<p>
Welcome to my personal webpage! I am a passionate web developer learning
the fundamentals of HTML. I enjoy creating clean and efficient code to
build beautiful and functional websites.
</p>
<h2>My Skills</h2>
<ul>
<li>HTML & CSS</li>
<li>JavaScript</li>
<li>Python</li>
<li>Problem Solving</li>
</ul>
<h2>Find Me Online</h2>
<p>
You can find my work on
<a href="https://github.com/labex-labs" target="_blank">GitHub</a>.
</p>
</div>
</body>
파일을 저장하고 Web 8080 탭을 새로고침하세요. 프로필 이미지와 클릭 가능한 링크가 표시될 것입니다.