初心者向けHTML入門の決定版:タグHTML

option要素・optionタグとは

Facebook にシェア
このエントリーをはてなブックマークに追加
Tweet

select要素内で生成される項目を表示option要素

option要素はselect要素内で生成される項目を表示します。
selectタグには最低でも1つ以上のoption要素が含まれている必要があります。

HTMLソースコード例

<form action="http://www.example.com" method="post">
  <select name="ComOS">
    <option selected label="none" value="none">None</option>
    <optgroup label="Windows">
      <option value="win2000">Windows 2000</option>
      <option value="xp">Windows XP</option>
      <option value="vista">Windows Vista</option>
    </optgroup>
    <optgroup label="Macintosh">
      <option value="lep">OS X 10.5 leopard</option>
      <option value="slep">OS X 10.6 snow leopard</option>
     </optgroup>
  </select>
</form>

ブラウザでの表示例


属性

selected
この属性が設定されている場合、当該選択肢が選択済みであることを示す。
value = cdata
コントロールの初期値を指定する。
label = text
option要素の内容より短いラベルを指定できる。

HTML要素(タグ)一覧

a  abbr  acronym  address  applet  area  b  base  basefont  bdo  big  blockquote  body  br  button  caption  center  cite  code  col  colgroup  dd  del  dfn  dir  div  dl  dt  em  fieldset  font  form  frame  frameset  h1 - h6  head  hr  html  i  iframe  img  input  ins  isindex  kbd  label  legend  li  link  map  menu  meta  noframes  noscript  object  ol  optgroup  option  p  param  pre  q  s  samp  script  select  small  span  strike  strong  style  sub  sup  table  tbody  td  textarea  tfoot  th  thead  title  tr  tt  u  ul  var  <!-- --> 

ブロックレベル要素一覧

p  h1-h6  ul  ol  dir  menu  pre  dl  div  center  noscript  noframes  blockquote  form  isindex  hr  table  fieldset  address 

インライン(テキストレベル)要素一覧

フォントスタイルに関するもの
tt  i  b  big  small
フレーズ・句に関するもの
em  strong  dfn  code  samp  kbd  var  cite  abbr  acronym
特別なもの
a  img  object  br  script  map  q  sub  sup  span  bdo
フォームに関するもの
input  select  textarea  label  button 

  • sitemap
  • 運営者情報
  • 免責事項
designed by ホームページ制作のササエル
Copyright © tagHTML All Rights Reserved.