Home  >  Article  >  Web Front-end  >  How to use the select tag in html

How to use the select tag in html

高洛峰
高洛峰Original
2017-03-24 11:47:431992browse

1. Drop-down radio selection

<select>
     <option value="=1">上海</option>
     <option value="=2" selected="selected">北京</option>
     <option value="=3">广州</option>
</select>

How to use the select tag in html

2. Show all options

There are two types here. You can only choose one option. Multiple selection

 <select size="3">
       <option>上海</option>
       <option>广州</option>
       <option>深圳</option>
 </select>
  
 <select multiple="multiple" size="3">
       <option>上海</option>
       <option>广州</option>
       <option>深圳</option>
 </select>

How to use the select tag in html

3. Element classification

<select>
      <optgroup label="河北省">
          <option>石家庄</option>
          <option>邯郸</option>
          <option>枣阳</option>
      </optgroup>
      <optgroup label="湖北省">
          <option>武汉</option>
          <option>咸宁</option>
          <option>赤壁</option>
      </optgroup>
      <optgroup label="河南省">
          <option>郑州</option>
          <option>安阳</option>
          <option>驻马店</option>
      </optgroup>
</select>

How to use the select tag in html

The above is the detailed content of How to use the select tag in html. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn