๐Ÿ“ŒLanguage/HTML & CSS

input type ์ข…๋ฅ˜ ์•Œ์•„๋ณด๊ธฐ, ์‚ฌ์šฉ๋ฐฉ๋ฒ•

hellohailie 2022. 4. 16. 16:01

ํผ ์š”์†Œ๋Š” ์„œ๋ฒ„์— ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•˜๊ธฐ ์œ„ํ•œ ์š”์†Œ์ด๋ฉฐ <input>์€ ๋Œ€ํ‘œ์ ์ธ ํผ ์š”์†Œ์ž…๋‹ˆ๋‹ค.

<input>์€ ๋‚ด์šฉ์ด ์—†๋Š” ๋นˆ ์š”์†Œ์ด๋ฉฐ type ์†์„ฑ์„ ํ†ตํ•ด ์—ฌ๋Ÿฌ ์ข…๋ฅ˜์˜ ์ž…๋ ฅ ์–‘์‹์œผ๋กœ ๋‚˜ํƒ€๋‚˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

 

    • type = "text"

See the Pen Untitled by HelloHailie (@hellohailie) on CodePen.

 

  • placeholder "text"์•ˆ์˜ ๊ธ€์ž
  • type = "password" ์ž…๋ ฅํ•˜๋ฉด ํŠน์ˆ˜๋ฌธ์ž๋กœ ๋‚˜์˜ค๊ฒŒ ๋œ๋‹ค. 

See the Pen Untitled by HelloHailie (@hellohailie) on CodePen.

 

  • type = "radio" 

ํ•œ ๊ฐœ๋งŒ ํด๋ฆญ๋˜๊ฒŒ ํ•˜๊ธฐ

name ์ด๋ผ๋Š” ์†์„ฑ์œผ๋กœ ๊ฐ™์€ ์„ฑ๊ฒฉ์˜ radio ๋ฒ„ํŠผ์ž„์„ ๋ช…์‹œํ•ด์ค˜์•ผ ํ•œ๋‹ค. 

์—ฌ์ž <input type="radio" name="gender">

๋‚จ์ž <input type="radio" name="gender">

 

 

 

See the Pen Untitled by HelloHailie (@hellohailie) on CodePen.

 

 

  • type = "checkbox" 

์ค‘๋ณต ์„ ํƒ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

See the Pen Untitled by HelloHailie (@hellohailie) on CodePen.

 

๋ณธ ๊ฐ•์˜์—์„œ๋Š” ๋‹ค๋ฃจ์ง€ ์•Š์•˜์ง€๋งŒ, ๋ผ๋””์˜ค ๋ฒ„ํŠผ๊ณผ ์ฒดํฌ๋ฐ•์Šค์—๋Š” checked, name ์†์„ฑ์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค.

checked ์†์„ฑ์€ ๊ฐ’์ด ๋ณ„๋„๋กœ ์กด์žฌํ•˜์ง€ ์•Š๋Š” boolean ์†์„ฑ์ž…๋‹ˆ๋‹ค.

boolean ์†์„ฑ์€ true/false ๋‘˜ ์ค‘ ํ•˜๋‚˜์˜ ๊ฐ’์„ ๊ฐ€์ง€๋ฉฐ ์†์„ฑ์ด ์กด์žฌํ•˜๋ฉด true, ์†์„ฑ์ด ์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด false๋ฅผ ๊ฐ€์ง‘๋‹ˆ๋‹ค.

ํ•ด๋‹น ์†์„ฑ์ด ์กด์žฌํ•˜๋ฉด ์‚ฌ์šฉ์ž๊ฐ€ ์ฒดํฌ๋ฅผ ํ•˜๊ฑฐ๋‚˜ ์„ ํƒ์„ ํ•˜์ง€ ์•Š๋”๋ผ๋„ ๋ฏธ๋ฆฌ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์ฒดํฌ, ์„ ํƒ๋œ ์ƒํƒœ๋กœ ๋‚˜์˜ค๊ฒŒ๋” ํ•˜๋Š” ์†์„ฑ!

 

 

See the Pen Untitled by HelloHailie (@hellohailie) on CodePen.

 

 

name ์†์„ฑ์€ ๋ผ๋””์˜ค ๋ฒ„ํŠผ๊ณผ ์ฒดํฌ๋ฐ•์Šค๋ฅผ ๊ทธ๋ฃนํ™”์‹œ์ผœ์ฃผ๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค.

์•„์ง name ์†์„ฑ์„ ๋‹ค๋ฃจ๊ธฐ ์ „์ด๋ฏ€๋กœ ์‹ค์ œ ๋ฒ„ํŠผ์„ ํด๋ฆญํ–ˆ์„ ๊ฒฝ์šฐ ๋™์ž‘ํ•˜๋Š” ๋ฐฉ์‹์— ๋Œ€ํ•ด์„œ๋งŒ ์•Œ์•„๋‘์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

 

 

  • type = "file" 

ํŒŒ์ผ์„ ์„œ๋ฒ„์— ์˜ฌ๋ฆด ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

 


 

  • type = "submit" 

๊ฐ’์„ ์ œ์ถœ, ์ „์†ก

value ๋ผ๋Š” ์†์„ฑ์œผ๋กœ ์ด๋ฆ„ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค. 

  • type = "reset" 

๊ฐ’ ์ดˆ๊ธฐํ™”

value ๋ผ๋Š” ์†์„ฑ์œผ๋กœ ์ด๋ฆ„ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค. 

  • type = "button"

์•„๋ฌด ๊ธฐ๋Šฅ์ด ์—†๋‹ค. ์ปค์Šคํ…€์ด ํ•„์š”ํ•˜๋‹ค. 

value ๋ผ๋Š” ์†์„ฑ์œผ๋กœ ์ด๋ฆ„ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค. 

 

 

 

 


 

  • type = "image"

์ด๋ฏธ์ง€ ๋ฒ„ํŠผ์€ ์ด๋ฏธ์ง€ ๊ด€๋ จ ์†์„ฑ์ธ src, alt ์†์„ฑ์ด ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•˜๋ฉฐ width/height ์†์„ฑ์„ ์ ์šฉํ•  ์ˆ˜๋„ ์žˆ๋‹ค. 

 

<input type = "image" src="./btnW_แ„Žแ…ฎแ†จแ„‹แ…ฃแ†จแ„’แ…งแ†ผ.png" alt="๋กœ๊ทธ์ธ" width="100" height="50">

 

 

๊ตฌ๊ธ€๋งํ•ด๋ณด๋‹ˆ ๋„ค์ด๋ฒ„์—์„œ ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ์„ ๋ฌด๋ฃŒ๋กœ ๋ฐฐํฌํ•˜๊ณ  ์žˆ์–ด์„œ ์‚ฌ์šฉํ•ด๋ดค์Šต๋‹ˆ๋‹ค. 

๊ฐ•์‚ฌ๋‹˜์€ submit, image ๋ฒ„ํŠผ์ด ์ œ๋Œ€๋กœ ์ž‘๋™ํ•˜๋Š” ๊ฒƒ ๊ฐ™์€๋ฐ ์ €๋Š” ์•„๋‹ˆ๋ผ์„œ ์ด ๋ถ€๋ถ„์€ ๋” ๊ณต๋ถ€๋ฅผ ํ•ด์•ผ๊ฒ ์Šต๋‹ˆ๋‹ค. 

https://developers.naver.com/docs/login/bi/bi.md

 

๋กœ๊ทธ์ธ ๋ฒ„ํŠผ ์‚ฌ์šฉ ๊ฐ€์ด๋“œ - LOGIN

๋„ค์ด๋ฒ„ ๋กœ๊ทธ์ธ์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋„ค์ด๋ฒ„ ๋กœ๊ทธ์ธ ๋ฒ„ํŠผ ๊ธฐ๋ณธ ์ด๋ฏธ์ง€๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์ƒํ™ฉ์— ๋งž๊ฒŒ ๋ฒ„ํŠผ ์ด๋ฏธ์ง€์˜ ๋””์ž์ธ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์ง€๋งŒ ๋„ค์ด๋ฒ„ ๊ณ ์œ ์˜ ์•„์ด๋ด

developers.naver.com

 


 

๐Ÿ‘‡๋” ๊ณต๋ถ€ํ•˜๊ธฐ ๐Ÿ‘‡

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input

 

<input>: The Input (Form Input) element - HTML: HyperText Markup Language | MDN

The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent. The <input> element

developer.mozilla.org