본문 바로가기

HTML

<button> vs <input>

<button>

- type="submit" : 폼 전송

- type="reset" : 폼 내용 초기화

- type="button" : 기능 구현에 주로 사용. (자바스크립트 이용)  


 type 속성은 반드시 지정하는 것이 바람직하며 지정하지 않을 경우 submit 기능을 수행


<input>

- button 과 같은 타입을 명시할 경우 동일한 기능 수행

(<button type="submit"></button>  <input type="submit">) 



w3schools 에서 설명하는 <button>

- Inside a <button> element you can put content, like text or images. This is the difference between this element and buttons created with the <input> element.

 <button>은 닫는 태그이므로 컨텐츠에 텍스트 뿐만 아니라 HTML요소도 받을 수 있다. 


- If you use the <button> element in an HTML form, different browsers may submit different values. Use <input> to create buttons in an HTML form.

 <button> 태그는 IE 구버전에서는 서버로 전송되는 값이 value가 아니라 컨텐츠이다.