HTML <버튼> 태그
예시
클릭 가능한 버튼은 다음과 같이 표시됩니다.
<button type="button">Click Me!</button>
아래에서 더 많은 "직접 사용해 보기" 예를 살펴보세요.
정의 및 사용
<button>
태그는 클릭 가능한 버튼을 정의합니다 .
요소 내부 에 텍스트(및 , ,
, , 등과 <button>
같은 태그)를 넣을 수 있습니다 . 요소 로 만든 버튼으로는 불가능합니다 !<i>
<b>
<strong>
<br>
<img>
<input>
팁: 항상 요소의 type
속성을 지정하여 <button>
브라우저에 어떤 유형의 버튼인지 알려주십시오.
팁: CSS로 버튼의 스타일을 쉽게 지정할 수 있습니다! 아래 예제를 보거나 CSS 버튼 튜토리얼을 방문하십시오.
브라우저 지원
Element | |||||
---|---|---|---|---|---|
<button> | Yes | Yes | Yes | Yes | Yes |
속성
Attribute | Value | Description |
---|---|---|
autofocus | autofocus | Specifies that a button should automatically get focus when the page loads |
disabled | disabled | Specifies that a button should be disabled |
form | form_id | Specifies which form the button belongs to |
formaction | URL | Specifies where to send the form-data when a form is submitted. Only for type="submit" |
formenctype | application/x-www-form-urlencoded multipart/form-data text/plain |
Specifies how form-data should be encoded before sending it to a server. Only for type="submit" |
formmethod | get post |
Specifies how to send the form-data (which HTTP method to use). Only for type="submit" |
formnovalidate | formnovalidate | Specifies that the form-data should not be validated on submission. Only for type="submit" |
formtarget | _blank _self _parent _top framename |
Specifies where to display the response after submitting the form. Only for type="submit" |
name | name | Specifies a name for the button |
type | button reset submit |
Specifies the type of button |
value | text | Specifies an initial value for the button |
전역 속성
<button>
태그는 HTML의 전역 속성도 지원 합니다 .
이벤트 속성
<button>
태그는 HTML의 이벤트 속성 도 지원합니다 .
더 많은 예
예시
CSS를 사용하여 버튼 스타일 지정:
<!DOCTYPE html>
<html>
<head>
<style>
.button {
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display:
inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button1 {background-color:
#4CAF50;} /* Green */
.button2 {background-color: #008CBA;} /* Blue */
</style>
</head>
<body>
<button class="button
button1">Green</button>
<button class="button button2">Blue</button>
</body>
</html>
예시
CSS를 사용하여 버튼 스타일 지정(호버 효과 포함):
<!DOCTYPE html>
<html>
<head>
<style>
.button {
border: none;
color: white;
padding: 16px 32px;
text-align: center;
text-decoration: none;
display:
inline-block;
font-size: 16px;
margin: 4px 2px;
transition-duration: 0.4s;
cursor: pointer;
}
.button1 {
background-color: white;
color: black;
border: 2px
solid #4CAF50;
}
.button1:hover {
background-color: #4CAF50;
color: white;
}
.button2 {
background-color: white;
color:
black;
border: 2px solid #008CBA;
}
.button2:hover {
background-color: #008CBA;
color: white;
}
</style>
</head>
<body>
<button class="button button1">Green</button>
<button class="button
button2">Blue</button>
</body>
</html>
관련 페이지
HTML DOM 참조: 버튼 객체
CSS 튜토리얼: 버튼 스타일 지정
기본 CSS 설정
없음.