Vizuna
Vizuna

Reputation: 241

How to align first row of table with a line of text

I want to align the first row of a table with a line of text. For example, I want to achieve

** some text ** |first row of table      |
                       |second row of table|
                       ...

When I use the <table> element it always puts the table on a new line, giving me

** some text **
|first row of table      |
|second row of table|
...

which I do not want.

I only know basic HTML, but not CSS. Still, any solution involving CSS is fine, I just want a quickfix.

Upvotes: 2

Views: 1789

Answers (3)

Vitorino fernandes
Vitorino fernandes

Reputation: 15951

or you can also use rowspan inside table

<table border="1">
  <tr>
    <td rowspan="2" valign="top">some text</td>
    <td>first row of table</td>
  </tr>
  <tr>
    <td>second row of table</td>
  </tr>
</table>

Upvotes: 4

Yogesh Khatri
Yogesh Khatri

Reputation: 1210

You can use display: inline-table to make table an inline element and align the table with the row.

e.g.

table {
    display: inline-table;
}

Upvotes: 1

SW4
SW4

Reputation: 71140

You could wrap the text in a span then do, e.g.:

span, table {
    float:left;
}
<span>some text</span>

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

Upvotes: 2

Related Questions