SEO 를 위해서는 a 태그가 정석이라고 한다.
<a> 태그와 <button> 태그의 차이점<a> 태그 (Anchor 태그)href(목적지 URL), target(새 탭 열기 등) <a href="https://example.com">이동하기</a><button> 태그type="button"(기본 버튼), type="submit"(폼 제출) <button onclick="alert('버튼 클릭됨!')">클릭하기</button><a> 태그를 사용해야 할까?<button> 태그를 사용해야 할까?<form> 안에서 type="submit") <button onclick="location.href='https://example.com'">이동하기</button>
<a> 태그가 더 적절합니다. <a href="https://example.com">이동하기</a>| 구분 | <a> 태그 | <button> 태그 |
|---|---|---|
| 주요 용도 | 페이지 이동 | 이벤트 실행, 폼 제출 |
| 기본 동작 | 클릭하면 링크로 이동 | 클릭하면 JS 실행 or 폼 제출 |
| SEO 영향 | 검색 엔진이 인식 | 검색 엔진이 인식 X |
| 속성 | href, target | type, onclick |
| 사용 예시 | 메뉴, 외부 링크, 페이지 이동 | 모달 열기, AJAX 요청, 폼 제출 |
📌 결론:
<a> <button>