9609c04755
W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더). - Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외) - Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체) - Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속) 각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
138 lines
5.7 KiB
Markdown
138 lines
5.7 KiB
Markdown
---
|
|
id: html-buttons
|
|
title: "HTML Buttons"
|
|
category: "Frontend"
|
|
status: "draft"
|
|
verification_status: "conceptual"
|
|
canonical_id: ""
|
|
aliases: ["button element", "HTML button", "button type", "submit button", "reset button"]
|
|
duplicate_of: ""
|
|
source_trust_level: "B"
|
|
confidence_score: 0.88
|
|
created_at: 2026-06-23
|
|
updated_at: 2026-06-23
|
|
review_reason: ""
|
|
merge_history: []
|
|
tags: ["html", "web", "frontend", "w3schools", "buttons", "forms"]
|
|
raw_sources: ["https://www.w3schools.com/html/html_buttons.asp"]
|
|
applied_in: []
|
|
github_commit: ""
|
|
---
|
|
|
|
# [[HTML Buttons]]
|
|
|
|
## 🎯 한 줄 통찰 (One-line insight)
|
|
The HTML `<button>` element defines a clickable button whose behavior is set by its `type` attribute (`button`, `submit`, or `reset`); you should always specify `type` because the in-form default differs and browsers behave inconsistently when it is omitted. [S1]
|
|
|
|
## 🧠 핵심 개념 (Core concepts)
|
|
- **`<button>` element** — defines a clickable button; by itself it does nothing until you add an action. [S1]
|
|
- **`type` attribute** — defines what the button does when clicked; three types: `button`, `submit`, `reset`. [S1]
|
|
- **Always set `type`** — inside a form the default type is `submit`, and browsers may behave differently if the type is omitted. [S1]
|
|
- **`disabled` attribute** — makes a button unclickable; disabled buttons usually appear faded. [S1]
|
|
- **Add behavior** — actions can be attached, e.g. with `onclick`. [S1]
|
|
|
|
## 🧩 추출된 패턴 (Extracted patterns)
|
|
- **Type-driven behavior** — `type="button"` (does nothing by default), `type="submit"` (submits a form), `type="reset"` (resets all form fields). [S1]
|
|
- **Form button pair** — a submit button plus a reset button inside a `<form>`. [S1]
|
|
- **Inline action** — `<button onclick="...">`. [S1]
|
|
- **Styling via class** — buttons are commonly styled with CSS through a class. [S1]
|
|
|
|
## 📖 세부 내용 (Details)
|
|
**The button element**
|
|
The HTML `<button>` element defines a clickable button. By itself, the button does nothing until you add an action to it. [S1]
|
|
```html
|
|
<button>Click Me</button>
|
|
```
|
|
|
|
**Button types**
|
|
The `type` attribute defines what a button does when clicked. There are three button types: [S1]
|
|
- `type="button"` — a normal clickable button (does nothing by default)
|
|
- `type="submit"` — submits a form
|
|
- `type="reset"` — resets all form fields
|
|
|
|
```html
|
|
<button type="button">Normal Button</button>
|
|
<button type="submit">Submit</button>
|
|
<button type="reset">Reset</button>
|
|
```
|
|
|
|
Example within a form: [S1]
|
|
```html
|
|
<form action="/action_page.php">
|
|
First name: <input type="text" name="fname">
|
|
<button type="submit">Submit</button>
|
|
<button type="reset">Reset Form</button>
|
|
</form>
|
|
```
|
|
|
|
**Note:** You should always specify the type attribute. Inside a form, the default type is submit, and browsers may behave differently if the type is omitted. [S1]
|
|
|
|
**Styling buttons**
|
|
Buttons are often styled with CSS: [S1]
|
|
```html
|
|
<button class="mytestbtn">Green Button</button>
|
|
```
|
|
|
|
**Disabled buttons**
|
|
Use the `disabled` attribute to make a button unclickable: [S1]
|
|
```html
|
|
<button disabled>Disabled Button</button>
|
|
```
|
|
**Tip:** Disabled buttons cannot be clicked and usually appear faded. [S1]
|
|
|
|
**Button with JavaScript**
|
|
```html
|
|
<button onclick="alert('Hello!')">Click Me</button>
|
|
```
|
|
|
|
## 🛠️ 적용 사례 (Applied in summary)
|
|
The applied cases are a plain clickable button, the three typed buttons, a submit/reset pair inside a form, a CSS-styled button, a disabled button, and a button that runs JavaScript via `onclick`. No external project/commit applications found in the source.
|
|
|
|
## 💻 코드 패턴 (Code patterns)
|
|
Typed buttons (HTML):
|
|
```html
|
|
<button type="button">Normal Button</button>
|
|
<button type="submit">Submit</button>
|
|
<button type="reset">Reset</button>
|
|
```
|
|
Button running JavaScript (HTML):
|
|
```html
|
|
<button onclick="alert('Hello!')">Click Me</button>
|
|
```
|
|
Disabled button (HTML):
|
|
```html
|
|
<button disabled>Disabled Button</button>
|
|
```
|
|
|
|
## ⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
|
|
The page presents three button types; choosing the right `type` is essential because the in-form default is `submit`: [S1]
|
|
|
|
| `type` value | Behavior when clicked | Use when |
|
|
|---|---|---|
|
|
| `button` | A normal clickable button; does nothing by default | You want a button with custom (e.g. JavaScript) behavior only |
|
|
| `submit` | Submits the form (the in-form default) | The button should send the form |
|
|
| `reset` | Resets all form fields | The button should clear the form |
|
|
|
|
Always specify the `type` to avoid inconsistent browser behavior when it is omitted. [S1]
|
|
|
|
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
|
No contradictions found in the source. Important caveat: omitting `type` inside a form defaults to `submit` and can cause divergent browser behavior, so it should always be set explicitly. [S1]
|
|
|
|
## ✅ 검증 상태 및 신뢰도
|
|
- **상태:** draft
|
|
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
|
|
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
|
- **신뢰 점수:** 0.88
|
|
- **중복 검사 결과:** 신규 생성 (New discovery)
|
|
|
|
## 🔗 지식 그래프 (Knowledge Graph)
|
|
- **상위/루트:** [[HTML Tutorial]]
|
|
- **관련 개념:** [[HTML Forms]], [[HTML Form Elements]], [[HTML Input Types]], [[HTML Accessibility]]
|
|
- **참조 맥락:** Referenced whenever adding clickable controls or form submit/reset actions to a page.
|
|
|
|
## 📚 출처 (Sources)
|
|
- [S1] W3Schools — HTML Buttons — https://www.w3schools.com/html/html_buttons.asp
|
|
|
|
## 📝 변경 이력 (Change history)
|
|
- 2026-06-23: Initial draft synthesized from the W3Schools "HTML Buttons" page (Astra wiki-curation, P-Reinforce v3.1 format).
|