Search code examples
html-tablealignment

Align inner table to right to text of outer table td


I have table with one one row and one cell.With in that cell some text and another table is there.What I am expecting is that the inner table should come at right to text,but its going to next line.How to achieve that?

Here is my code...

<!DOCTYPE HTML>
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head>

     <body>
      <table border="1">
       <tr>
        <td>
          Here is some text 
          <!-- Inner Table. This table should come at right to the above text-->
          <table style="border:1px solid blue;">
            <tr>
             <td>1</td>
             <td>Krish</td>
            </tr>

             <tr>
             <td>2</td>
             <td>Alex</td>
            </tr>

          </table>
        </td>
       </tr>
      </table>

     </body>
    </html>

Solution

  • you should specify float:right or float:left

    As per your html, specify table with float:right as

    <table style="border:1px solid blue;float:right;">