HTML input type image 기능과 alt 속성

HTML input type image

<input type = "image"> 는 제출용 버튼을 이미지로 만드는 방법입니다. 이미지 주소의 값이 버튼으로 생성됩니다.

image 속성값은 value 속성을 가지지 않습니다. 이미지를 원하는 주소값을 src 속성뒤에 적습니다.

그림을 클릭하면 이미지 버튼 효과로 전송이 됩니다. 물론 현재는 아무 연결이 없으므로 이미지를 클릭하면 404 page가 나옵니다.

<input type="image" src="주소">

alt 대체 텍스트

일반 <img> 태그 처럼 이미지가 나오지 않는다면 alt 속성에 적힌 값이 대신 노출됩니다. 물론 <input type="image"> 자체가 버튼의 기능을 하므로 그림이 삭제되어도 클릭의 본연 기능은 작동됩니다.

<input type="image" src="http://dasima.xyz/wp-content/uploads/2019/01/html-input-image-102.png">
<br>
<input type="image" src="http://dasima.xyz/wp-content/uploads/2019/01/html-input-image-1022.png" alt="그림이 삭제되었습니다.">