html/css 독학하기

optgroup

토픽 html/css 독학하기 > html사전

설명

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) 인터넷 익스플로러 모바일 오페라 모바일 사파리 모바일
기본적인 지원          

참고

댓글

댓글 본문