Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Align the tr of a table horizontally

I have a table :

https://codepen.io/greg59650/pen/GROajNp

    <table role="table"><tbody>
      <tr>
       <td colspan="1">
      <form>
      <select name="pets" id="pet-select">
       <option value="">choose</option>
       <option value="dog">Dog</option>
       <option value="cat">Cat</option>
      </select>    
      </form>
       </td>    
        <td colspan="1">
       <form>
         <select name="pets" id="pet-select">
          <option value="">choose</option>
          <option value="dog">Dog</option>
          <option value="cat">Cat</option>
         </select>
          <span><button>Logout</button></span>
         </form>
          </td>    
        <td colspan="1">
        <form>
          <select name="pets" id="pet-select">
            <option value="">choose</option>
            <option value="dog">Dog</option>
            <option value="cat">Cat</option>
           </select>    
        </form>
        </td>
        <td colspan="1">
       <form>
       <select name="pets" id="pet-select">
        <option value="">choose</option>
        <option value="dog">Dog</option>
        <option value="cat">Cat</option>
       </select>    
      </form>
       </td>
       <td colspan="1">
      <form>
      <select name="pets" id="pet-select">
       <option value="">choose</option>
       <option value="dog">Dog</option>
        <option value="cat">Cat</option>
       </select>    
       </form>
       </td>
       <td colspan="1">
       <form>
       <select name="pets" id="pet-select">
       <option value="">choose</option>
       <option value="dog">Dog</option>
       <option value="cat">Cat</option>
     </select>    
      </form>
     </td>
    <td colspan="1">
     <form>
      <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
    </td>
       </tr></tbody></table>

if I add an element in the content of my td I would like all my selects to be aligned on the same level and the button below.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

like this :

enter image description here

but currently I get this display :

enter image description here

would there be a simple solution to be able to align the selects on the same level ?

>Solution :

You can add vertical-align: top to your td.

td {
    vertical-align: top;
}
table {border:1px solid black; }
td {
  vertical-align: top;
}
<table role="table"><tbody>
  <tr>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>
    <span><button>Logout</button></span>
  </form>
</td>    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
  <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
    <td colspan="1">
  <form>
  <select name="pets" id="pet-select">
    <option value="">choose</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
  </select>    
  </form>
</td>
</tr></tbody></table>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading