[html] form

XIXIยท2022๋…„ 5์›” 4์ผ
0

๋Œ€๊ตฌAI์Šค์ฟจ

๋ชฉ๋ก ๋ณด๊ธฐ
11/57
post-thumbnail
<body>
    <!-- a
        - href : ๋งํฌ์˜ ๋ชฉ์ ์ง€
        -target : ์ฐฝ ์—ฌ๋Š” ํ˜•ํƒœ _self, _blank
    -->
    <ul>
        <li><a href="https://www.naver.com/" target="_blank">๋„ค์ด๋ฒ„</a></li>
        <li><a href="https://chrome.google.com/" taeget="_blank"><img src="" width="50px">๊ตฌ๊ธ€</a></li>
    </ul>
    <br><br>
    <ul>
        <li><a href="#ch1">Where does thos spec fit?</a></li>
        <li><a href="#ch2">Is this html?</a></li>
    </ul>
    <!-- id, ์ค‘๋ณต ์‚ฌ์šฉ ๋ถˆ๊ฐ€๋Šฅ, ํŽ˜์ด์ง€ ์•ˆ์—์„œ ์œ ์ผํ•จ -->
    <p id="ch1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eius delectus laboriosam ut quibusdam odit ea aliquam officia temporibus. Inventore debitis, nisi aut temporibus totam quae et molestias officiis eius enim.</p>
</body>

a ํƒœ๊ทธ

  • href โžช ๋งํฌ์˜ ๋ชฉ์ ์ง€
  • target โžช ์ฐฝ์„ ์—ฌ๋Š” ํ˜•ํƒœ
  • _self โžช ์—ด๋ฆฐ ํŽ˜์ด์ง€ ๋‚ด
  • _black โžช ์ƒˆ๋กœ์šด ํŽ˜์ด์ง€
  • id โžช ์ค‘๋ณต ์‚ฌ์šฉ ๋ถˆ๊ฐ€๋Šฅ, ํŽ˜์ด์ง€ ์•ˆ์—์„œ ์œ ์ผ

โœ๏ธForm

<body>
    <!--
    [ ํผ ํƒœ๊ทธ ์†์„ฑ ]
        name: ์Šคํฌ๋ฆฝํŠธ๋‚˜ ์„œ๋ฒ„์—์„œ from์„ ์‹๋ณ„ํ•˜๊ธฐ ์œ„ํ•œ ์ด๋ฆ„
        action: from๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•  ๋•Œ URL ์ง€์ •
        method:  HTTP ์š”์ฒญ ๋ฉ”์†Œ๋“œ(get, post)
            -get: ๋ฐ์ดํ„ฐ๋ฅผ URL์˜ ์ผ๋ถ€๋กœ ์ „์†ก 
            -post: ๋ฐ์ดํ„ฐ๋ฅผ ๋ณธ๋ฌธ์œผ๋กœ ์†ก์‹ 
        target: ์›น ์„œ๋ฒ„ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์œผ๋กœ๋ถ€ํ„ฐ ์ „์†ก๋ฐ›์€ ๋ฐ์ดํ„ฐ(HTML ๋ฌธ์„œ๋‚˜ ์ด๋ฏธ์ง€๋ฅผ ์ถœ๋ ฅํ•  ์œˆ๋„์šฐ ์ด๋ฆ„)
    -->
    <form name="fo" method="get">
        ์•„์ด๋””: <input type="text" size="15"><br>
        ๋น„๋ฐ€๋ฒˆํ˜ธ: <input type="password" size="15"><br>
        <input type="submit" value="Log in"><br>
    </form>

    <!-- ํผ ์ „์†ก๊ณผ์ • -->
    <form name="sform"
        action="https://search.naver.com/search.naver"
        method="get">
    <input type="text" name="query">
    <input type="submit" value="๊ฒ€์ƒ‰">
    </form>
</body>

form

  • name โžช ์Šคํฌ๋ฆฝํŠธ๋‚˜ ์„œ๋ฒ„์—์„œ from์„ ์‹๋ณ„ํ•˜๊ธฐ ์œ„ํ•œ ์ด๋ฆ„
  • action โžช from๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•  ๋•Œ URL ์ง€์ •
  • method โžช HTTP ์š”์ฒญ ๋ฉ”์†Œ๋“œ(get, post)
  • get โžช ๋ฐ์ดํ„ฐ๋ฅผ URL์˜ ์ผ๋ถ€๋กœ ์ „์†ก(์™ธ๋ถ€์— ๋…ธ์ถœ)
  • post โžช ๋ฐ์ดํ„ฐ๋ฅผ ๋ณธ๋ฌธ์œผ๋กœ ์†ก์‹ 
  • target โžช ์›น ์„œ๋ฒ„ ์‘์šฉํ”„๋กœ๊ทธ๋žจ์œผ๋กœ๋ถ€ํ„ฐ ์ „์†ก๋ฐ›์€ ๋ฐ์ดํ„ฐ(HTML ๋ฌธ์„œ๋‚˜ ์ด๋ฏธ์ง€๋ฅผ ์ถœ๋ ฅํ•  ์œˆ๋„์šฐ ์ด๋ฆ„)

โœ๏ธForm tag

์ž๊ธฐ์†Œ๊ฐœ์„œ

<h3>์ž๊ธฐ์†Œ๊ฐœ์„œ ์ž‘์„ฑ</h3>
    <form>
        ์ด๋ฆ„: <input type="text" value="" size="15"><br>
        ์•”ํ˜ธ: <input type="password" value="" size="15" maxlength="4"><br>
        ์ž๊ธฐ์†Œ๊ฐœ์„œ: <br>
        <textarea rows="5" cols="20" placeholder="์—ฌ๊ธฐ์— ์ž…๋ ฅํ•˜์„ธ์š”"></textarea>

์ž๊ธฐ์†Œ๊ฐœ์„œ form

  • maxlength โžช ์ž…๋ ฅ ๊ธ€์ž ์ตœ๋Œ€ ๊ธธ์ด
  • rows โžช ํ–‰
  • cols โžช ์—ด
  • placeholder โžช ์ž…๋ ฅ ์ „ ํ‘œ์‹œํ•  ๊ฐ’, ๋ฐ์ดํ„ฐ ์ž…๋ ฅ ์‹œ ์‚ฌ๋ผ์ง.

Datalist/Selected

<!-- ๋ฐ์ดํ„ฐ ๋ชฉ๋ก์„ ๊ฐ€์ง„ ํ…์ŠคํŠธ ์ž…๋ ฅ: datalist (์ž๋™์™„์„ฑ๊ธฐ๋Šฅ) -->
<h3>์„ ํ˜ธ๊ณผ์ผ</h3>
<input type="text" list="fruit">
	<datalist id="fruit">
		<option value="apple"></option>
		<option value="banana"></option>
		<option value="cheery"></option>
    </datalist>

๋จน๊ณ ์‹ถ์€ ์Œ์‹์€
<!-- ์ฝค๋ณด๋ฐ•์Šค ๋งŒ๋“ค๊ธฐ, selected ๊ธฐ๋ณธ์„ ํƒ -->
<select name="china">
	<option value="1">์งœ์žฅ๋ฉด</option>
	<option value="2">์งฌ๋ฝ•</option>
	<option value="3" selected>ํƒ•์ˆ˜์œก</option>
</select>

Datalist/Selected

data list์™€ ์ฝค๋ณด๋ฐ•์Šค๋Š” ๋งŒ๋“œ๋Š” Select์ฐจ์ด๋Š”

  • datalist โžช ์‚ฌ์šฉ์ž ์ž…๋ ฅ ๊ฐ€๋Šฅ
  • select โžช ๋ชฉ๋ก์—์„œ๋งŒ ์„ ํƒ ๊ฐ€๋Šฅ
  • selected โžช ํ‘œ์‹œ ๋ฐ์ดํ„ฐ ๊ฐ’, ์„ ํƒ์œจ์ด ๋งŽ์€ ๋ฐ์ดํ„ฐ ๊ฒฝ์šฐ ์ถ”๊ฐ€ ์„ ํƒ์˜ ๋นˆ๋„๋ฅผ ์ค„์ž„.

Label ํผ ์š”์†Œ ์บก์…˜

<!-- ๋ผ๋””์˜ค๋ฒ„ํŠผ -->
<label><input type="radio" name="friut2">๋ฐ”๋‚˜๋‚˜</label><br>
<label><input type="radio" name="friut2" checked disabled>ํฌ๋„</label><br>  <!--checked disable ์ˆ˜์ • ๋ถˆ๊ฐ€๋Šฅ-->
<label><input type="radio" name="friut2">์ˆ˜๋ฐ•</label><br>
        
<label for="addr">์‚ฌ๋Š” ๊ณณ: </label>
<input type="text" id="addr">

<label>์ข‹์•„ํ•˜๋Š” ์ƒ‰๊น”์€?</label><br>
<label>๋นจ๊ฐ•<input type="checkbox" value="1"></label><br>
<label>ํŒŒ๋ž‘<input type="checkbox" value="2"></label><br>
<label>๋…ธ๋ž‘<input type="checkbox" value="3"></label><br>

Label ํผ ์š”์†Œ ์บก์…˜

label for="addr" , input type="" id="addr" ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๊ฐ๊ฐ ์˜์—ญ์ด ํ•˜๋‚˜์˜ ์˜์—ญ์ž„์„ ํ‘œํ˜„ํ•ด์ฃผ๋Š” ๊ฒƒ.

name์„ ๋™์ผํ•˜๊ฒŒ ์ ์šฉํ•˜๋Š” ์ด์œ ๋Š” friut2์„ ๋‹ค๋ฅด๊ฒŒ ์ฃผ๋ฉด ์ค‘๋ณต ์„ ํƒ์ด ๋จ. ๋•Œ๋ฌธ์— ๊ฐ™์€ ๊ฐ’์„ ์ฃผ์–ด์„œ ํ•˜๋‚˜๋งŒ ์„ ํƒํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•จ.

  • label โžช ์„ ํƒ ๋ถ€๋ถ„ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๊ธ€์ž๋ฅผ ํด๋ฆญํ•ด๋„ ์„ ํƒ์ด ๊ฐ€๋Šฅํ•˜๋„๋ก

์ƒ‰ ์ž…๋ ฅ ํƒœ๊ทธ

<!--
์ƒ‰ ์ž…๋ ฅ
#FFFFF (rgb => #rrggbb) / 0~255(8bit) / 0~FF
-->

<label>๊ธฐํƒ€: <input type="color" value="#00BFF"
            onchange="document.body.style.color=this.value">
			<input type="checkbox" value="4"></label>

์ƒ‰ ์ž…๋ ฅ์€
#FFFFF (rgb => #rrggbb) / 0~255(8bit) / 0~FF ๋“ฑ ๋‹ค์–‘ํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ๊ฐ€๋Šฅ.

  • onchange="document.body.style.color=this.value" โžช ์ „์ฒด ์ƒ‰์ƒ ๋ณ€๊ฒฝ

์‹œ๊ฐ„์ •๋ณด ํƒœ๊ทธ

<h3>์‹œ๊ฐ„์ •๋ณด์ž…๋ ฅ</h3>
    <input type="momth" value="2010-12"><br>
    <input type="week" value="2022-W30"><br>
    <input type="date" value="2012-01-01"><br>
    <input type="datetime-local" value="2012-01-01T06:10:10"><br>
    <input type="time" value="21:30"><br>

์Šคํ•€๋ฒ„ํŠผ ์Šฌ๋ผ์ด๋“œ๋ฐ”

<!-- ์Šคํ•€๋ฒ„ํŠผ๊ณผ ์Šฌ๋ผ์ด๋“œ๋ฐ” -->
<h3>ํ™ˆ ์ œ์–ด ์‹œ์Šคํ…œ</h3>
<form>
	์ง€์†์‹œ๊ฐ„(0.0~10.0์‹œ๊ฐ„):
	<input type="number" min="0.0" max="10.0" step="0.5"><br>
	์˜จ๋„์„ค์ •:10&deg;
	<input type="range" min="10" max="30" list="temp">30&deg;
		<datalist id="temp">
            <option value="12" label="Low"></option>
            <option value="20" label="Medium"></option>
            <option value="28" label="High"></option>
        </datalist>
</form>

<!-- ํผ ์š”์†Œ ๊ทธ๋ฃนํ•‘ fieldset / legend(์ œ๋ชฉ) -->
<h3>์ •๋ณด์ž…๋ ฅ</h3>
<hr>
<form>
<fieldset>
  <legend>์ œ๋ชฉ์„ ์ž…๋ ฅ</legend>
    <input type="email" placeholder="id@host">
    <input type="url" placeholder="https://">
    <input type="tel" placeholder="010-0000-0000">
    <input type="search" placeholder="๊ฒ€์ƒ‰์–ด">
    <input type="submit" placeholder="์ „์†ก">
  </fieldset>
  <small>๋ฌธ์˜: Tel.010-0000-0000</small>
</form>
</body>

  • fieldset โžช from ์š”์†Œ ๊ทธ๋ฃนํ•‘
  • legend โžช ์ œ๋ชฉ

โœ๏ธํ‘œ ๊ตฌ์กฐํ™”

<body>
	<table>
		<caption>์ œ์ฃผํŠน๋ณ„์ž์น˜๋„ ํ•™๊ตํ˜„ํ™ฉ(2015.4.1 ๊ธฐ์ค€)</caption>
		<thead>
			<th>๊ตฌ๋ถ„</th>
			<th>ํ•™๊ต์ˆ˜</th>
			<th>ํ•™๊ธ‰์ˆ˜</th>
			<th>ํ•™์ƒ์ˆ˜</th>
			<th>๊ต์›์ˆ˜</th>
		</thead>
		<tbody>
			<tr>
				<td>์œ ์น˜์›</td>
				<td>117</td>
				<td>252</td>
				<td>5,547</td>
				<td>474</td>
			</tr>
			<tr>
				<td>์ดˆ๋“ฑํ•™๊ต</td>
				<td>117</td>
				<td>252</td>
				<td>5,547</td>
				<td>474</td>
			</tr>
			<tr>
				<td>์ค‘ํ•™๊ต</td>
				<td>117</td>
				<td>252</td>
				<td>5,547</td>
				<td>474</td>
			</tr>
			<tr>
				<td>๊ณ ๋“ฑํ•™๊ต</td>
				<td>117</td>
				<td>252</td>
				<td>5,547</td>
				<td>474</td>
			</tr>
		</tbody>
		<tfoot>
			<tr>
				<td>ํ•ฉ๊ณ„</td>
				<td>304</td>
				<td>3,347</td>
				<td>86,954</td>
				<td>6,111</td>
			</tr>
		</tfoot>
	</table>

ํ‘œ ๊ตฌ์กฐํ™”

  • caption โžช ์ œ๋ชฉ
  • thead โžช ํ‘œ ๊ตฌ๋ถ„ ํƒ€์ดํ‹€
  • tbody โžช ๋‚ด์šฉ
  • tfoot โžช ์ดํ•ฉ(์–ด๋”” ์œ„์น˜ํ•ด๋„ ํ‘œ ํ•˜๋‹จ์— ๋ถ™์Œ)

๐Ÿƒ ์–ด๋ ค์› ๋˜ ์  or ํ•ด๊ฒฐ๋ชปํ•œ ๊ฒƒ

์˜คํƒ€๊ฐ€ ๋‚˜์„œ ์‹คํ–‰์ด ๋˜์ง€ ์•Š์•˜๋Š”๋ฐ ์ฐพ๊ธฐ ํž˜๋“ค์—ˆ๋‹ค.

๐Ÿ€ ํ•ด๊ฒฐ๋ฐฉ๋ฒ• ์ž‘์„ฑ

์ฒœ์ฒœํžˆ ์‚ดํŽด๋ณด๋ฉด์„œ ํƒœ๊ทธ๋“ค์ด ์ง์„ ์ž˜ ์ด๋ฃจ๊ณ ์žˆ๋Š”์ง€ ์ฒ ์ž๊ฐ€ ํ‹€๋ฆฌ์ง€์•Š์•˜๋Š”์ง€ ํ™•์ธํ•จ.

๐ŸŒท ํ•™์Šต ์†Œ๊ฐ

์ฐจ๊ทผ์ฐจ๊ทผ ์•Œ์•„๊ฐ€๋Š” ๊ธฐ๋ถ„์ด ๋“ ๋‹ค.

profile
Life is experience:)

0๊ฐœ์˜ ๋Œ“๊ธ€