πŸ’»Coding/πŸ““ HTML

HTML <select> νƒœκ·Έ - μ„ νƒλ°•μŠ€ (폼 form 양식

μŒμ€μ‘ 2021. 8. 4. 15:42
728x90
λ°˜μ‘ν˜•

HTML <select> νƒœκ·Έ - μ„ νƒλ°•μŠ€ (폼 form 양식)

HTML <select> → μ„ νƒλ°•μŠ€

- <select>~</select>으둜 ν΄λ‘œμ§• νƒœκ·Έλ₯Ό μž‘μ„±ν•΄μ•Όν•©λ‹ˆλ‹€.

- <select>λŠ” 선택 μ˜΅μ…˜ νƒœκ·Έλ‘œ <option>~</option>νƒœκ·Έ μš”μ†Œλ₯Ό 1개 이상 κ°€μ§€κ³  μžˆμ–΄μ•Όν•©λ‹ˆλ‹€.

- <select> 전체 ν•­λͺ© μ•ˆμ—μ„œ μ„ νƒλœ<option>~</option>은 μ„œλ²„λ‘œ μ „μ†‘μ΄λ©λ‹ˆλ‹€.

 

[ select νƒœκ·Έμ˜ κΈ°λ³Έ ν˜•νƒœ ]

↓ <select>νƒœκ·ΈλŠ” 전체 선택 ν•­λͺ©λ“€μ„ 감싸고 <option> νƒœκ·ΈλŠ” 각 ν•­λͺ©μ„ κ°μ‹ΈλŠ” ν˜•νƒœμž…λ‹ˆλ‹€.

<select>
	<option>μ˜΅μ…˜ λ‚΄μš©</option>
</select>

 

<option>μ—μ„œ 자주 μ“°λŠ” 속성
→ selected
  • selected : μ˜΅μ…˜λ“€ μ€‘μ—μ„œ 미리 μ„ νƒλ˜μ–΄μ§€λŠ” μ˜΅μ…˜μ„ μ§€μ •ν•˜λŠ” μ†μ„±μœΌλ‘œ selectedλ₯Ό μ“΄ <option>의 μˆœμ„œμ™€ 상관없이 κ°€μž₯ λ¨Όμ € ν‘œμ‹œκ°€ λ©λ‹ˆλ‹€.

 

[ μ‹€μ „μ˜ˆμ‹œ ]

<form>
        이메일 : <input type="text" name="email" placeholder="아이디" autofocus> @ 
        <select>
            <option>직접 μž…λ ₯</option>
            <!-- <option>naver.com</option> -->
            <option selected>naver.com</option>
            <option>gmail.com</option>
            <option>nate.com</option>
            <option>hanmail.com</option>
        </select>
</form>

 

[ μ‹€ν–‰μ‹œ ν™”λ©΄ ]

html code μ‹€ν–‰ page

728x90
λ°˜μ‘ν˜•