Search code examples
htmldropdown

specify label's position to be above of the dropdown menu in html


How can I specify the position of the label to be above the dropdown menu?

E.g.

<form action="/action_page.php">
  <label for="cars">Choose a car:</label>
  <select name="cars" id="cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="opel">Opel</option>
    <option value="audi">Audi</option>
  </select>
  <input type="submit" value="Submit">
</form>

Is there any style argument in <label for="cars">Choose a car:</label> that would place it above the menu?

Thank you!


Solution

  • Because label is an inline element, you can't give it a size unless you change its display option to block or inline-block

     <label for="cars" style="display:block;">Choose a car:</label>
    

    MSDN explaination.