简体   繁体   中英

Aligning table data at the top

I want to align a table data at the top. Example.

data-- I want to align this at top text.... - this contains a lot of text that makes the first table data at the center

Like this:

            klasdjlkasjdlsakjdlk
            kldjaslkdjsadkjasldj
            dlasjidlaskdjlaksjdl
  asdasd    ajsdlkasjdlaskjdlkas
            laksjdlaksdjsalkdjak
            adlksjdlasjdkasjdlka

I want it to be like this.

asdasd      klasdjlkasjdlsakjdlk
            kldjaslkdjsadkjasldj
            dlasjidlaskdjlaksjdl
            ajsdlkasjdlaskjdlkas
            laksjdlaksdjsalkdjak
            adlksjdlasjdkasjdlka

Any ideas?

Define in your css td vertical-align :top and text-align :left

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

without css

<td valign="top" align="left"> // here your data </td>

这只是一个标准的HTML表吗?

  <td valign="top">text</td>

Here is how to do it without CSS:

<table width="100" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td valign="top">
        asdasd
        </td>
        <td>
        klasdjlkasjdlsakjdlk
        kldjaslkdjsadkjasldj
        dlasjidlaskdjlaksjdl
        ajsdlkasjdlaskjdlkas
        laksjdlaksdjsalkdjak
        adlksjdlasjdkasjdlka
        </td>
    </tr>
</table>

It is best to do this with CSS, rather than inline as you'll have more flexibility and your code will be leaner and easier to read.

If you only want to do it for particular cells, then consider using classes.

For inline (not recommended), use the following:

<td valign="top">...</td>

To use css, use the following in your stylesheet:

td { vertical-align: top; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM