HTML Form How to - Align select and input elements on a form








Question

We would like to know how to align select and input elements on a form.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
ul {<!--from w  ww.j  a  va  2  s  . c om-->
  height: 100px;
  background-color: #EEE;
}

li {
  float: left;
  list-style-type: none;
  margin-top: 20px;
}

#li1 {
  width: 250px;
}

h4 {
  margin: 0;
}
</style>
</head>
<body>
  <ul>
    <li id="li1">
      <h4>Name</h4> 
      <input text-align="top" name="" id="" size="30" value="bob"
      type="text">
    </li>
    <li class="select input required" id="">
      <h4>Available Value</h4> 
      <select id="" name="">
        <option value="1.0" selected="selected">1.0</option>
        <option value="0.9">0.9</option>
        <option value="0.8">0.8</option>
    </select>
    </li>
  </ul>
</body>
</html>

The code above is rendered as follows: