이미지를 넣을 수 있는 img 태그를 배우다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<!-- 이미지 태그: 웹 문서에 이미지를 보여줄 때 사용하는 태그
src 속성: 이미지 경로
alt 속성: 이미지 오류 발생 시 보여지는 텍스트-->
<!-- 절대경로: 어떤 폴더나 파일이 가진 고유한 경로, 이미지 주소 복사 -->
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEBASEhAVEBUQDxASEBUQDxAPERAQFRUXFhUWFRUYHSggGBonGxUVITEhJSkrLi4uFx8zODMsNygtLisBCgoKDg0OGhAQGy0lHyYtLi0tLSstLS0tLi0tLS0tLS0tLi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0vNf/AABEIAOEA4QMBIgACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAABQYCBAcDAf/EAEEQAAIBAgMFBAYHBwIHAAAAAAABAgMRBAUhBhIxQVETYXGhIjKBkbHBBxRCUmJy0SMzQ1OCkuEV8BYXJESisvH/xAAaAQEAAwEBAQAAAAAAAAAAAAAAAgMEAQUG/8QAJxEAAgMAAgMAAQMFAQAAAAAAAAECAxESMQQhQSIyUXEzYYGRsRP/2gAMAwEAAhEDEQA/AO4gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8sTiIwjvSdl5vwRX8bnE56R9CPd6z8XyIykkX1ePOzrr9ycxOPpw4y16LVkdVzz7sP7n8kQlwip2Nm+Hhwj37JKWbVXzS8Ir5nnLMar/iP2WRpXPtyPJlqpgviNyOYVV/EftszYpZzNcUpeyzIy4uFJnHTB9oseGzWnLR+g/xcPeb5TTewGZSp6P0o9Hy8CyNn7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zm9ZP4L2EJFIvFXZCnJtutUvJtt+hq3q+Rh/wAGUv5tT/w/QpcJN6enX5FUIqKZVcHTvJLvLZh42ij3wuy9ODuqk347v6G+ssj95+ROEc7Kb74zfo0qZ63NtZevvPyMvqK+8/It1GfmjSuEzd+orq/IfUl1fkd1DmjURg2b/wBTXV+Ri8Cur8jmjmiMqo0sxpb0H4E/LL4v7T8jznlUWrbz8g8aJRsSelDyep2eKoz4WqKMvyy9F/E6YVuWx9Nu/azWt/sfoWOCskr3skr9SqCaJ+VZCxpxPoAJmUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/9k=" alt="이미지를 불러올 수 없음">
<!-- 상대경로: 특정 위치를 기준으로 폴더나 파일을 접근하는 경로 (주로 사용)
현재 위치 기준: ./폴더명/파일명.확장자 or 폴더명 (./ = 현재 폴더 위치를 뜻함)
루트 위치 기준: 최상위 폴더에서 접근하는 방식
상위 위치 기준: 상위 폴더로 올라가서 접근하는 방식 ../ (../ = 상위 폴더로 1칸 가기)
-> ../폴더명/파일명.확장자 or ../파일명.확장자 -->
<img src="img/루피.jpg" alt="이미지를 불러올 수 없음" width="150" height="150">
<img src="/HTML/img/싹도노.png" alt="">
</body>
</html>
이미지를 불러올 수 있는 태그 img 태그는 src, alt 속성을 가진다.
src는 이미지의 경로, alt는 이미지를 불러오는데 오류가 발생했을 시 나타나는 텍스트이다.
이미지의 경로는 크게 2가지로 나뉘는데 절대 경로, 상대 경로가 있다.
절대 경로는 쉽게 이미지를 우클릭하여 이미지 주소 복붙하면 된다.
주로 사용하는 상대 경로는 내 저장소에서 이미지 파일 위치를 찾아서 입력하면 된다.
내가 쉽게 생각한 것은 한 칸씩 이동하여 가계도에서 특정 인물 찾는 것처럼 생각하니 이해가 됐다.
코드의 파일과 이미지 파일이 같은 폴더에 위치하면./를 사용해서 시작하고,
바깥 폴더에 있다면 ../를 사용해서 상위 폴더로 나가서 이동하면 된다.
(자세한 내용은 코드의 주석을 참고하자)
'Front-End > HTML' 카테고리의 다른 글
[HTML] Ex06_테이블.html (0) | 2023.06.10 |
---|---|
[HTML] Ex05_앵커태그.html (0) | 2023.06.10 |
[HTML] Ex03_글자태그.html (0) | 2023.06.10 |
[HTML] Ex02_문단태그.html (0) | 2023.06.09 |
[HTML] Ex01_basic.html (0) | 2023.06.09 |