valign vs text-align in HTML

sandbox picture sandbox · Jan 6, 2012 · Viewed 27.4k times · Source

I can't figure out the difference between valign vs text-align in HTML in context with the following code:

    <table width="500" border="0">
  <tr>
        <td colspan="2" style="background-color:#FFA500;">
   <h1>Main Title of Web Page</h1>
   </td>
      </tr>

  <tr valign="top">
      <td style="background-color:#FFD700;width:100px;text-align:top;">
      <b>Menu</b><br />
    HTML<br />
      CSS<br />
  JavaScript
     </td>
   <td style="background-color:#EEEEEE;height:200px;width:400px;text-align:top;">
      Content goes here</td>
    </tr>

   <tr>
     <td colspan="2" style="background-color:#FFA500;text-align:center;">
     Copyright © 2012</td>
   </tr>
   </table>

Answer

jenson-button-event picture jenson-button-event · Jan 6, 2012

valign (html attribute) is equivalent of vertical-align in css

align (html attribute) is equivalent of text-align in css

html attribute versions are deprecated in favour of css

vertical-align positions block elements (e.g. div) vertically inside other block elements

text-align positions inline elements (e.g. span, default text) inside block elements horizontally