How to align columns of unequal contents

flexbox
equal height columns flexbox
flex; align right
flex-basis
css equal height columns
flexbox height fit content
css equal height columns responsive
flex cheat sheet css-tricks

If contents of one column are more than contents of other columns in a table then by default browser aligns the contents of columns with lesser contents to be vertical-align: inherit.

tr {
  page-break-inside: avoid;
}

table,
td,
th {
  border: 1px solid black;
}

span {
  margin: 10px;
}
<table>
  <tr>
    <th>1</th>
    <th>2</th>
    <th>3</th>
  </tr>
  <tr>
    <td>
      <span>Column 1</span>
    </td>
    <td>
      <span>Column 2</span>
    </td>
    <td>
      <p>This is para 1</p>
      <p>This is para 2</p>
      <p>This is para 3</p>
      <p>This is para 4</p>
      <p>This is para 5</p>
      <p>This is para 6</p>
      <p>This is para 7</p>
      <p>This is para 8</p>
    </td>
  </tr>
</table>

Your problem is that in addition to vertical-align: top; for the td tag you need to change the default CSS of the p tag. Once you remove the margin-top the text will go to the top of the cell.

I added these changes:

td {
  vertical-align: top;
}

p {
  margin-top: 0;
}

See snippet below:

tr {
  page-break-inside: avoid;
}

table,
td,
th {
  border: 1px solid black;
}

td {
  vertical-align: top;
}

span {
  margin: 10px;
}

p {
  margin-top: 0;
}
<table>
  <tr>
    <th>1</th>
    <th>2</th>
    <th>3</th>
  </tr>
  <tr>
    <td>
      <span>Column 1</span>
    </td>
    <td>
      <span>Column 2</span>
    </td>
    <td>
      <p>This is para 1</p>
      <p>This is para 2</p>
      <p>This is para 3</p>
      <p>This is para 4</p>
      <p>This is para 5</p>
      <p>This is para 6</p>
      <p>This is para 7</p>
      <p>This is para 8</p>
    </td>
  </tr>
</table>

Aligning rows of different columns with unequal rows, Hello, I am stumped, I cannot figure out how to align two columns that and the table lays out the one to many values this way in the table. Hello, I am stumped, I cannot figure out how to align two columns that sometimes have rows that are unequal in number. The data is sourced from a web page that has a table layout and the table lays out the one to many values this way in the table.

Just use valign attribute to your td valign="top" for smaller content. Optionally to make it center and bottom aligned content use valign-center and valign-bottomas follow.

<!DOCTYPE html>
<html>

<head>
    <style>
        tr {
            page-break-inside: avoid;
        }
        
        table,
        td,
        th {
            border: 1px solid black;
        }
        
        span {
            margin: 10px;
        }
    </style>
</head>

<body>

    <table>
        <tr>
            <th>1</th>
            <th>2</th>
            <th>3</th>
        </tr>
        <tr>
            <td valign="top">
                <p>Column 1</p>
            </td>
            <td valign="top">
                <p>Column 2</p>
            </td>
            <td>
                <p>This is para 1</p>
                <p>This is para 2</p>
                <p>This is para 3</p>
                <p>This is para 4</p>
                <p>This is para 5</p>
                <p>This is para 6</p>
                <p>This is para 7</p>
                <p>This is para 8</p>
            </td>
        </tr>
    </table>
</body>

</html>

Fluid Width Equal Height Columns, Equal height columns have been a need of web designers forever. THE PROBLEM: Three columns with different amounts of content only grow as tall as they need to individually. width: 20%; padding: 10px; vertical-align: top; } #​actual-table td:nth-child(even) { background: #ccc; } The fallback is simply uneven columns. 1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window. 2. Click Insert > Module, and paste the following code in the Module Window. VBA code: Align duplicates or matching 3. Then press F5 key to run this code, after executing the code, a new column will be

try this

tr {
  page-break-inside: avoid;
}

table,
td,
th {
  border: 1px solid black;
  vertical-align: top;
}
<!DOCTYPE html>
<html>

<body>

  <table>
    <tr>
      <th>1</th>
      <th>2</th>
      <th>3</th>
    </tr>
    <tr>
      <td>
        Column 1
      </td>
      <td>
       Column 2
      </td>
      <td>
        This is para 1<br>
        This is para 2<br>
        This is para 3<br>
        This is para 4<br>
        This is para 5<br>
        This is para 6<br>
        This is para 7<br>
        This is para 8<br>
      </td>
    </tr>
  </table>
</body>

</html>

Everything You Need To Know About Alignment In Flexbox , If my flex-direction were column then align-content would work as in the following example. HTML; CSS; JS. Result. How to align unequal hierarchical linear arrangements? I have 2 child vertical Linear Layouts in a parent horizontal LinearLayout (i.e. 2 columns). The column on the left has only 5 items with fixed height (number blocks), while the column on the right has a lot more items with variable height (5 questio

Use valign like this:

<table>
  <tr>
    <th>1</th>
    <th>2</th>
    <th>3</th>
  </tr>
  <tr>
    <td valign="top">
      <span>Column 1</span>
    </td>
    <td valign="top">
      <span>Column 2</span>
    </td>
    <td>
      <p>This is para 1</p>
      <p>This is para 2</p>
      <p>This is para 3</p>
      <p>This is para 4</p>
      <p>This is para 5</p>
      <p>This is para 6</p>
      <p>This is para 7</p>
      <p>This is para 8</p>
    </td>
  </tr>
</table>

How to set flexbox having unequal width of elements using CSS , The margin doesn't collapse with the content margins. Order of any element can be easily changed without editing the HTML section. But few times we have an unequal width of the element also that time you can div class = "columns" >This is 2nd column</ div > How to vertically align text inside a flexbox using CSS? Vertical Align: Set your Column Content's vertical alignment. This way, you will be able to stick the content of all the columns of a section to the bottom, the middle or the top or "stretch to fill" to align columns with unequal heights. Choose from Top, Middle, Bottom, Space Between, Space Around, Space Evenly

CSS Box Alignment, .box { display: grid; width: 540px; grid-template-columns: 120px 120px 120px; align-items: start; justify-content: space-between; } .box :first-child  The align-content property modifies the behavior of the flex-wrap property. It is similar to align-items, but instead of aligning flex items, it aligns flex lines. Note: There must be multiple lines of items for this property to have any effect! Tip: Use the justify-content property to align the items on the main-axis (horizontally).

10 tips for working with Word columns, When you need to align text across the page from column to column (in Columns usually make content more readable because of the shorter  To AutoFit column width, select one, several or all columns on the sheet, go to the Home tab > Cells group, and click Format > AutoFit Column Width. To AutoFit row height, select the row (s) of interest, go to the Home tab > Cells group, and click Format > AutoFit Row Height. AutoFit column width and row height using a keyboard shortcut

Mastering Word Made Easy: Versions 2007 Through 97, For example, if you had three adjacent columns of unequal sizes in a table, you in the Ribbon to change the alignment of the cell content for any selected cells. I'm trying to center two columns on my website but there are some problems. The result of every change is left position (see picture). What am I doing wrong? Here's my CSS: body { background -

Comments
  • Can you share your CSS?
  • @oram I have added the css in head section.
  • notice the contents are above the "This is para 1" text
  • I have updated the snippet. If you use p tag instead span the become same line.