Html-select-tag

提供:Dev Guides
移動先:案内検索

HTML-<select>タグ

説明

HTML <select>タグは、選択リストを定義するためにフォーム内で使用されます。

<!DOCTYPE html>
<html>

   <head>
      <title>HTML select Tag</title>
   </head>

   <body>
      <form action = "/cgi-bin/dropdown.cgi" method = "post">

         <select name = "dropdown">
            <option value = "Data Structures" selected>Data Structures</option>
            <option value = "Data Mining">Data Mining</option>
         </select>

         <input type = "submit" value = "Submit"/>
      </form>
   </body>

</html>

これは、次の結果を生成します-

グローバル属性

このタグは、− link:/html/html_attributes_reference [HTML属性リファレンス]で説明されているすべてのグローバル属性をサポートします

特定の属性

HTML <select>タグは、次の追加属性もサポートしています-

Attribute Value Description
autofocus html-5 autofocus Specifies that on page load the drop-down list should automatically get focus.
disabled disabled Disables the input control. The button won’t accept changes from the user. It also cannot receive focus and will be skipped when tabbing.
form html-5 form_id Specifies one or more forms.
multiple multiple When set, it specifies that multiple items can be selected at a time
name name Assigns a name to the input control.
required html-5 required Before submitting the form the user is required to select a value, else it won’t proceed ahead.
size number Defines the number of visible items in the drop-down list

イベント属性

このタグは、link:/html/html_events_reference [HTMLイベントリファレンス]で説明されているすべてのイベント属性をサポートしています。

ブラウザのサポート

Chrome Firefox IE Opera Safari Android
Yes Yes Yes Yes Yes Yes