HTMLでプルダウンの選択メニューを表示する方法/Select・Optionタグの使い方

girl IT

お問い合わせやアンケートページなどで活用できる、プルダウンリストをHTMLで実装する方法のご紹介となります。

スポンサーリンク

Select・Optionタグの使い方

プルダウンリストの範囲
<select></select>
プルダウンリストの項目
<option></option>

つまり箪笥がselectタグで引き出しがoptionタグです。

<select><option>頭</option><option>おなか</option><option>尻尾</option></select>

と記入した場合は、

という具合に表示されます。

複数選択可能リスト

selectにmultipleを付けると、複数選択可能なリストを表示できます。

複数選択可能リストの範囲
<select multiple></select>

サイズ変更

Selectにsizeを付けることで、縦の長さを変更することができます(プルダウンではなくなります)。

サイズの指定
<select size=”(数字)”></select>

たとえばsize=”7″だとこうなります。

multipleと併用する場合は、size=”7″ multipleでもmultiple size=”7″のどちらでもかまいません。

HTMLの便利な使い方・タグ逆引きリファレンス
ウェブページ作成言語として常に熱い需要を持つHTML関連のまとめページです。 勉強しながらちょっとずつ増やしていく所存です。

コメント

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny