본문 바로가기
  • 개발 / 공부 / 일상
HTML&CSS

(HTML) Input 태그

by JJeongHyun 2023. 1. 9.
반응형

Input 태그

  • 사용자가 데이터를 입력하는 영역, type 종류는 정말 많다
  • 그중 text는 글을 적을 수 있는 텍스트 창을 제공해주는 type 속성 값
  • name 속성은 서버에 보내는 데이터의 이름을 설정하고, 그 이름을 같이 부른다
  • id속성은 label 태그와 연결하기 위해 사용
<input type="text" id="text" name="ersar" />

label 태그

  • 입력값에 대한 제목을 사용자에게 보여준다. (ex. 성명, 이름, 번호, 메일 등)
  • for 속성은 input 태그와 연결하기 위해 사용한다. 클릭 시 for속성에 알맞은 input id선택자를 찾아서 입력할 수 있게 해 준다. (focus 이동)
<label for="text">아무거나 입력해 보세요</label>

 

password 속성

  • input type 속성에 password 속성 설정을 하면 input 태그에 입력한 데이터가 출력하면에는 "*****"로  나타낸다.
<label for="pw">PW<input type="password" id="pw" name="pw" /></label>

 

url, search 속성

  • http 주소나 검색창을 설정 값으로 부여할 수 있다
<label for="url">주소 :</label>
<input type="url" id="url" name="url" />

<label for="search">검색어를 입력하세요 :</label>
<input type="search" id="search" />

 

checkbox 속성

  • 기본적으로 조그만한 네모에 클릭 시 체크할 수 있는 영역을 나타낸다.
  • 만일, checked 설정하면 체크를 안 해도 체크가 된 상태로 출력이 된다
<label for="checkbox">동의 하시겠습니까 </label>
<input type="checkbox" id="checkbox" checked />

 

email 속성

  • 이메일 형식에 맞춰서 입력하지 않으면 경고메세지가 출력된다
<label for="email">이메일 :</label>
<input type="email" id="email" />

 

radio 속성

  • 중복이 되지 않는 여러 개의 체크박스 형식의 설정
  • 중복을 허용하는 설정으로 하려면 name 값을 설정하여 할 수 있다
<div> 좋아하는 과일은 ?
	<input type="radio" id="radio1" name="radio" />
	<label for="radio1">사과</label>
	
	<input type="radio" id="radio2" name="radio" />
	<label for="radio2">오렌지</label>
	
	<input type="radio" id="radio3" name="radio" />
	<label for="radio3">바나나</label>
	
	<input type="radio" id="radio4" name="radio1" />
	<label for="radio4">중복되는 과일</label>
</div>

 

※ 그 밖에 form 태그 안이 아니라 외부 영역에서도 label의 for 속성과 input id 속성 값들이 서로 같다면 위치와 상관없이 label 클릭 시 input으로 커서가 이동된다

 

 

button 태그

  • 버튼을 생성하여 누를 수 있는 창을 생성한다
  • 기본적으로 작동하는 게 없어서 JS를 넣어야 하지만 a 태그처럼 무조건 작동하는 게 없어서 편하다
  • type 속성에는 어떠한 작동을 할 것인지 기본 작동을 설정한다
  • submit 값은 form 데이터를 보낼 때 사용한다
  • a 태그와 다른 점 a태그는 다른 웹페이지로 이동할 때 사용하고 그 외 모든 면에서 사용한다.
<button type="submit">보내기 </button>

<button>
	<img
	src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxAQEA8QDxAPDw0NDw4NEA0PEA8NDg0NFREWFhURFRUYHSggGBolHRUVITEtJSkrLi4uFx82ODMsNygtLisBCgoKDg0OGBAQGi0dICUtLSsuLSstKy0vLS0tLS0rKy0tKy0tLTMwKy01LS0tMC8vKy0wLS0tLS0rLS0tLS0tLf/AABEIAOEA4QMBIgACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAAAgMBBAUGB//EAD0QAAIBAwEGAgcGBAUFAAAAAAABAgMEETEFEiFBUWETcQYHIoGRobEUMlJiwfAjM3LRQoKisuE0VGOS8f/EABsBAQACAwEBAAAAAAAAAAAAAAACBAEDBQYH/8QAOxEAAgECAwUGBQAHCQAAAAAAAAECAxEEITEFEkFRcRNhgZGh8CIyscHhBhQVI0Ki0TM0NXJzgrLC8f/aAAwDAQACEQMRAD8A+kgAwdoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArqVUtf+Sn7Yu/vOZPbOChLddS/RNrzSsSUW9EbQK6VaMtNehYdCnUhUipwd0+KMNWAAJmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3ZXYABjJSqbRw0NZrwzBkoua26v3o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VTjr7T+C+R1sPsnEVVdLdXOWXpr6EJ4iEeNzlUqWUmT8I37imk8RSSXIq3TnYun2NSUL3s2vIiqjeZC12fOq3GnHLWW9EsebNepQcW1JNSXBprDTPbbGtPCpRyvbnicuvZe5fqZ2ns2FZcfZqJezNa+XdHa/YU3h4zT+PVp6dy7msvHzOf+0rVWn8vP7njbKwlVnGEeer5Jc2zs7R9GVjeoZylxpt53u6fJ9tPI7GytnKhDHBzlxnJfJLsjdwX8HsimqFq6vKX8vJJ8+fB6ZpGqttCbqXpvJevvh+T5rOk02mmmuDTWGn0aPS7N2BB27VVYq1cTUudJY9lfq137HZudnUqk4TnHMoNPOmcaKXVfvQ2WMFsdUak3VtNaLo9W1z4eZmvtB1IRUPher/H1PnN3bSpTlTmsODw+j6NdmWWeqPReltonCNZLjTahLvDk/c/9x5y0fE4OMw36tXcNVqunvLwOnRrdtSU/Pr7z8T02PYh7/0MCm8049m18V/wD2ODadCFuRzlxAALJkAAAAAAAAAAAAEZRymupIBpNWYOBduUG0//AKaU5tnqKtKMliSTXcpjYUlx3F78s8xU/R+al+7kt3vvdemZcjiUlmjh2djKo+i5tndtbGFPRZl+J6l8UlwXBdESOtg9mUsP8T+KXN8Oi4ddTTVrSnlogADomk0bn7zFlS36kI8pTSfx4/Ilcass2P8Az6X9T/2nhMRBS2huvR1LfzWN7dqbfc/oeuZEkRPd3ucAEWZMMGTBFkiLMEkam1KW/Qqx603j+pLK+aR4S2fE+iNZ4deB86t9Uea2/H4qUuq8rf1Oxsxvdmunrf8AoemtXml5NfqSK7L+W/cWHY2c74eJF/M+oABeMAAAAAAAAAAAAAAAAAAGDIAAAABp3OrJbJ/6il5v6MA8Rif8RX+ov+Rul/ZPo/oevIgHtjhAwADJFkWACSET5zb6gHnf0g1o/wC7/qdbZmk/D7npLD+XLyX1RYAdTZn93RiXzMAAvmAAAAAAAAAD/9k="
	alt=""
	/>
</button>
<button type="reset">입력값 초기화</button>

 

textarea 태그

  • 여러 줄을 입력 가능한 input text이라고 보면 된다.
<textarea cols="30" rows="10"></textarea>

 

 

select 태그

  • 선택하는 입력값, 다만 한 칸에 보여준다
    • option 태그 : 선택할 메뉴들이고 특히 value의 속성값이 매우 중요하다
      value는 보낼 데이터를 의미, select 태그의 자식으로 들어가야 한다
<div>
	<select>
		<option value="seoul">서울</option>
		<option value="2">경기도</option>
		<option value="c">강원도</option>
		<option value="ㅁ">부산</option>
	</select>
</div>

'HTML&CSS' 카테고리의 다른 글

(CSS) padding, margin  (4) 2023.01.11
(HTML) video, audio, etc Tags  (0) 2023.01.09
(HTML) form Tag  (0) 2023.01.09
(HTML) Table Tag  (0) 2023.01.09
(HTML) Tags(2)  (0) 2023.01.09