HTML5 동영상강좌 바로가기

html - label태그

본문

label

<label>태그는 주로 폼양식에서 아이템(input태그 등)에 설명을 붙일 때 사용합니다.

 

속성

for설명을 붙이려는 아이템의 ID값을 지정하게 됩니다.

 


샘플

<!DOCTYPE html>
<html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <meta name="author" content="코리아뉴스" />
 <title> html공부 </title>
 <link rel="stylesheet" type="text/css" href="default.css" / >
 <style type="text/css">
 body {
 color:red;
 }
 </style>
 </head>
 <body>
  <section>
   <h1>label태그</h1>        
   <form action="" method="post">
   <fieldset>
   <legend>폼 테스트</legend>
   <label for ="fname">성명</label>
   <input id="fname" type="text" placeholder="실명으로" autofocus required>
   <label for ="fe-mail">이메일</label>
   <input id="femail" type="email" placeholder="abc@abc.com">
   <label for ="fphone">전화번호</label>
   <input id="fphone" name="phone" placeholder="02-1111-1111" required>
   <label for ="fsubject">선호과목</label>
   <select name="fsubject">
    <optgroup label="전공1">
    <option value="html">html</option>
    <option value="css">css</option>
    <option value="java">java</option>
    </optgroup>
    <optgroup label="전공2">
    <option value="리눅스">리눅스</option>
    <option value="보안">보안</option>
    <option value="프로그램">프로그램</option>
    </optgroup>
    <optgroup label="전공3">
    <option value="html5">html5</option>
    <option value="css3">css3</option>
    <option value="javascript">javascript</option>
    </optgroup>
   </select>
   <label for ="fcontent">내용</label>
   <textarea name="fcontent" rows="5" cols="90">내용을 적으세요</textarea>
   </fieldset>
   <fieldset>
   <input type="submit" value="저장">
   <button name="button">클릭하여 힌트를 얻으세요.</button>
   </fieldset>        
   </form>      
  </section>
  <div id="related">
   <p>영역 </p>
  </div>
  <footer>
      <address> 전화 : 031-574-3659, E-mail : master@koreanews.com </address>
                             Copyright ⓒ 2013 Koreanews co.,  All Rights Reserved.
  </footer>
 </body> 

</html>  


HTML5 동영상강좌 바로가기