็ก์
Form Tag ๊ตฌ์ฑ ์์ (1/2) ๋ณธ๋ฌธ
๐ฆ Form Tag
์ฌ์ฉ์๊ฐ ์ ๋ ฅํ ๊ฐ์ ์๋ฒ๋ก ์ ์กํ๋ ์์์ ์์์ ์ผ๋ก, ์ ๋ ฅ์์๋ฅผ ๋ฌถ์ด ์ ์ถ(์ ์ก) ๊ตฌ์กฐ๋ฅผ ๋ง๋ ๋ค.
๐ต ๊ตฌ์ฑ ์์ 5๊ฐ์ง
๐ธ <form>
ํผ ์ ์ฒด๋ฅผ ๊ฐ์ธ๋ ์ปจํ ์ด๋.
๐ธ <fieldset>, <legend>
๊ตฌ์กฐ์ ์ผ๋ก ๋ฌถ๊ณ ์๋ฏธ๋ฅผ ๋ถ์ฌํ๋ ์ญํ .
- <fieldset>: ๊ด๋ จ๋ ์ ๋ ฅ ์์๋ค์ ํ๋์ ๊ทธ๋ฃน์ผ๋ก ๋ฌถ๋ ํ๊ทธ. (๊ธฐ๋ณธ์ ์ผ๋ก ๋ฐ์ค ๋ชจ์ ์์ฑ)
- <legend>: <fieldset>์ ์ ๋ชฉ(์บก์ ) ์ญํ ํ๊ทธ. (<fieldset> ์์์ ๊ฐ์ฅ ์ฒซ ๋ฒ์งธ ์์๋ก ์ฌ์ฉ.)
๐ธ <label>, <textarea>
์ ๋ ฅ๊ณผ ์ ๊ทผ์ฑ์ ๋ด๋นํ๋ ์ค์ํ ์์.
- <label>: ์
๋ ฅ ์์(input)์ ์ค๋ช
(๋ผ๋ฒจ)์ ๋ถ์ด๋ ํ๊ทธ.
- <label for="username">์์ด๋:</label>
<input type="text" id="username"> : ์ฌ์ฉ์๊ฐ ๋ผ๋ฒจ์ ํด๋ฆญํ๋ฉด ํด๋น ์ ๋ ฅ์นธ์ด ์๋์ผ๋ก ์ ํ๋์ด ํธ๋ฆฌ.
- <label for="username">์์ด๋:</label>
- <textarea>: ํ ์ค ์ด์์ ํ
์คํธ ์
๋ ฅ ํ๋.
- row: ์ธ๋ก ์ค ์. (์ด)
- cols: ๊ฐ๋ก ๊ธ์ ์. (์นธ)
- placeholder: ์๋ด ๋ฌธ๊ตฌ.
- maxlenght: ์ต๋ ๊ธ์ ์.
๐ธ <select>, <option>
์ฌ๋ฌ ํญ๋ชฉ ์ค ํ๋ ๋๋ ์ฌ๋ฌ ๊ฐ๋ฅผ ์ ํํ ๊ฒฝ์ฐ ์ฌ์ฉํ๋ ๋๋กญ๋ค์ด ๋ชฉ๋ก.
- <select>: ์ ํ ๋ชฉ๋ก ์ ์ฒด๋ฅผ ๋ง๋๋ ํ๊ทธ.
- name: ์๋ฒ๋ก ์ ์กํ ๋ ์ฌ์ฉํ ์ด๋ฆ.
- multiple: ์ฌ๋ฌ ํญ๋ชฉ ์ ํ ๊ฐ๋ฅ.
- size: ํ ๋ฒ์ ๋ณด์ด๋ ์ต์ ๊ฐ์.
- <option>: ๋ชฉ๋ก ์์์ ๊ฐ ์ ํ ํญ๋ชฉ์ ์ ์.
- value: ์ค์ ๋ก ์๋ฒ์ ์ ์ก๋๋ ๊ฐ.
- selected: ๊ธฐ๋ณธ ์ ํ ํญ๋ชฉ.
๐ธ <button>
ํด๋ฆญ ๊ฐ๋ฅํ ๋ฒํผ์ ๋ง๋๋ ํ๊ทธ.
๐โ <input type="submit">๊ณผ ๋น์ทํ์ง๋ง, ํ ์คํธ๋ฟ ์๋๋ผ ์ด๋ฏธ์ง๋ ์์ด์ฝ๋ ๋ฃ์ ์ ์์ด ๋์์ธ ์์ ๋๊ฐ ๋๋ค.
- type="submit": ํผ ๋ฐ์ดํฐ ์ ์ถ. (๊ธฐ๋ณธ๊ฐ)
- type="reset": ํผ ์ ๋ ฅ ์ด๊ธฐํ.
- type="button": ์ผ๋ฐ ๋ฒํผ. (JavaScript์ ํจ๊ป ์ฌ์ฉ)
๐โ POINT ๐โ
โ๏ธโ <label> ํ๊ทธ๋ ์ด์ฉ์์ ํธ์์ฑ๊ณผ ์น ์ ๊ทผ์ฑ์ ์ํด ๊ผญ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข๋ค. โ๏ธ
โ๏ธโ <textarea> ํ๊ทธ๋ </textarea> ๋ซ๋ ํ๊ทธ ์ฌ์ด์ ๋ด์ฉ์ ์์ฑํ๋ฉด ํผ ๋ก๋ ์ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ํ์ ๋๋ค. โ๏ธโ
โ๏ธโ <selsct> ํ๊ทธ์์ ํน์ ํญ๋ชฉ์ ๋ฏธ๋ฆฌ ์ ํํด๋๊ณ ์ถ๋ค๋ฉด <option> selscted ์์ฑ์ ์ถ๊ฐํ๋ค. โ๏ธโ
๐ ํค์๋๋ณ ํต์ฌ ์์ฝํ ๐
| ํ๊ทธ | ์ญํ | ์ฃผ์ ์์ฑ |
| <label> | ์ ๋ ฅ์ฐฝ ์ค๋ช ๋ฐ ์ฐ๊ฒฐ | for (id์ ์ฐ๊ฒฐ) |
| <textarea> | ์ฌ๋ฌ ์ค ํ ์คํธ ์ ๋ ฅ | rows, cols |
| <button> | ํด๋ฆญ ๊ฐ๋ฅํ ๋ฒํผ | type (submit, reset, button) |
| <select> | ๋๋กญ๋ค์ด ๋ชฉ๋ก ์์ | name |
| <option> | ๋ชฉ๋ก์ ๊ฐ๋ณ ํญ๋ชฉ | value, selected |
| <fieldset> | ์ ๋ ฅ ์์ ๊ทธ๋ฃนํ | (ํ ๋๋ฆฌ ์์ฑ) |
| <legend> | ๊ทธ๋ฃน์ ์ ๋ชฉ ์ ์ | (fieldset ๋ด๋ถ ์ต์๋จ) |
โ๏ธ ์คโ์ ์์ ์ฝ๋ โ๏ธ
<form action="/submit-inquiry" method="post">
<fieldset>
<legend>๋ฌธ์ ๋ด์ฉ ์์ฑ</legend>
<label for="category">๋ฌธ์ ์ ํ:</label>
<select id="category" name="category">
<option value="tech">๊ธฐ์ ์ง์</option>
<option value="billing">๊ฒฐ์ ๊ด๋ จ</option>
<option value="etc" selected>๊ธฐํ</option>
</select>
<br><br>
<label for="message">์์ธ ๋ด์ฉ:</label><br>
<textarea id="message" name="message" rows="5" cols="30" placeholder="๋ด์ฉ์ ์
๋ ฅํด ์ฃผ์ธ์."></textarea>
<br><br>
<button type="submit">๋ฌธ์ํ๊ธฐ</button>
<button type="reset">๋ค์ ์ฐ๊ธฐ</button>
</fieldset>
</form>
'<div>' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| Input Tag ์์ฑ (1/2) (0) | 2026.03.11 |
|---|---|
| Form Tag ์์ฑ (2/2) (0) | 2026.03.11 |
| ๋ฉํฐ๋ฏธ๋์ด ํ์ผ (0) | 2026.03.10 |
| ์ด๋ฏธ์ง ํฌ๋งท (0) | 2026.03.10 |
| Hyper link Tag (0) | 2026.03.10 |