HTML 사전

optgroup

설명

In a web form, the HTML optgroup element (<optgroup>) creates a grouping of options within a <select> element.

웹의 폼에서, HTML optgroup element(<optgroup>)은 <select> element 안의 option들의 묶음을 만든다. (그룹핑할 수 있다.)

Usage Context

Permitted content Zero or more <option> elements.
Tag omission The start tag is mandatory. The end tag is optional if this element is immediately followed by another <optgroup> element, or if the parent element has no more content.
Permitted parent elements A <select> element.
Normative document HTML 5, Section 4.10.11; HTML 4.0.1, Section 17.6

속성

이 엘리먼트는 전역속성을 지원한다.

disabled

If this Boolean attribute is set, none of the items in this option group is selectable. Often browsers grey out such control and it won't received any browsing events, like mouse clicks or focus-related ones.

만약 이 Boolean 속성이 사용되면, 이 option group안에 있는 아이템들은 선택할 수 없게 된다. 브라우저에 따라 그러한 컨트롤을 회색으로 표기해주기도 하며, 마우스 클릭이나 포커스등의 어떤 브라우즈내 이벤트도 받지 않는 상태가 된다.

label

The name of the group of options, which the browser can use when labeling the options in the user interface. This attribute is mandatory if this element is used. 

Note : Optgroup elements may not be nested.

예제

<select>
  <optgroup label="Group 1">
    <option>Option 1.1</option>
  </optgroup> 
  <optgroup label="Group 2">
    <option>Option 2.1</option>
    <option>Option 2.2</option>
  </optgroup>
  <optgroup label="Group 3" disabled>
    <option>Option 3.1</option>
    <option>Option 3.2</option>
    <option>Option 3.3</option>
  </optgroup>
</select>

DOM Interface

 

호환성

Desktop
기능 구글크롬 파이어폭스Gecko) 인터넷 익스플로러 Opera Safari
기본적인 지원          
Mobile
기능 안드로이드 파이어폭스 모바일(Gecko) 인터넷 익스플로러 모바일 오페라 모바일 사파리 모바일
기본적인 지원          

참고

댓글

댓글 본문
  1. engfordev
    수고하셨습니다 ^^
    의견 함 읽어보시고, 적절하게 적용해주세요~ 좀 갸우뚱한 부분이 있으시다면, 역시나 의견을 본문에 써주시면 되겠습니다.
    --
    1. web form 뭐라고 표현하면 좋을지~ 용어사전에 추가해두었습니다 ^^
    https://docs.google.com/spread...
    다만 웹의 폼 보다는 웹용 입력양식 등의 표현이 어떨까요?입력양식도 좀 일반인에게는 생소하게 들리기는 하지만, 그나마 엑셀 같은 데서 본 적이 있어서 좀 낫지 않을까도 싶고요. ㅎㅎ
    2. 설명부분..
    저는 이렇게 써 봤어요~
    <optgroup> 요소는 <select>요소 안에서 option들을 그룹으로 묶어줄 때 사용한다.
    3. disabled 부분
    저는 다음과 같이 써봤어요 ^^
    <optgroup> 요소 안에 불리언 속성인 disabled를 써주면, 이 </optgroup><optgroup> 안에 있는 <option>아이템을 비활성화되며 선택할 수 없게 된다. 이런 경우 브라우저에서는 회색으로 표시해주고, 마우스 클릭이나 포커스 등의 이벤트에 반응하지 않는다. </option></optgroup></select></optgroup>
버전 관리
김나솔
현재 버전
선택 버전
graphittie 자세히 보기