Shaquille Ray
Shaquille Ray

Reputation: 183

HTML Table Question

When you create a basic HTML table everything seems to stay in center of the table. I don't want this how can i stop this from happening?

I wish to use a 2 column html table one for column for a sidebar one for content. Because i have so much content the sidebar text (which is little) gos to the middle of column.

How do i align the text to stay to the top left of the columns?

Upvotes: 3

Views: 413

Answers (5)

Lenny Magico
Lenny Magico

Reputation: 1203

<table>
     <tr valign="top">
        <td align="left">
           Side Bar
        </td>
        <td>
           Content
        </td>
     </tr>
</table>

Upvotes: 0

Kit Z. Fox
Kit Z. Fox

Reputation: 674

You can control the alignment of columns directly in your markup by using:

<td style="text-align: left; vertical-align: top;"></td>

or even just

<td align="left"></td>

This will work fine for a 2-column table, but Piccolomomo has the better plan if you are going to use it a lot. This might help you further if you need it: http://www.w3schools.com/html/html_tables.asp

Upvotes: 1

IllvilJa
IllvilJa

Reputation: 228

In the <td> element that contains the lefthand sidebar, try specifying a style that aligns text to the top:

<td style="vertical-align: top">(Sidebar HTML code here)</td>

Upvotes: 1

NewUser
NewUser

Reputation: 13323

For aligning text in table you have to use css.Without css or any style sheet you can't make them align.So you can use inline css or external css for that.

<style type="text/css">
table td{
text-align:left;
vertical-align:top;
}
</style>

Upvotes: 0

Piccolomomo
Piccolomomo

Reputation: 58

You can use CSS to change text aligning inside your table:

td {
    text-align: left;
    vertical-align: top;
}

Upvotes: 0

Related Questions