HTML: Align Text in Table at the Top
Question by Guest | Last update on 2023-11-02 | Created on 2016-07-23
I have some tables on my website, in which cells there are texts of different lengths. Sometimes only a word, sometimes several sentences.
Unfortunately, the text in the cell is centered vertically. However, I want the text to start always at the top left corner above and not somewhere in the middle.
Is this somehow possible using HTML formatting?
Related Topics
Lord's Prayer in 20 other Languages
Info | 0 Comments
Total Lunar Eclipses in Germany - Dates
Info | 0 Comments
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
MySQL: Delete Data from Table - Difference between TRUNCATE, DELETE and DROP
Tutorial | 0 Comments
Delphi: CanvasTextOut: Align Left, Right and Center
Tip | 0 Comments
SQLite: Check whether Table exists
Info | 0 Comments
HTML/CSS: Align entire Table Column right or centered
Question | 4 Answers
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Just set the property vertical align (valign) of the corresponding cell to "top".
For example, this will align the first column to the top:
So, just insert valign="top" for the td's of choice - and the text should stick at the top.
Last update on 2023-11-02 | Created on 2016-07-23
Alternatively, you can also work with CSS. The corresponding CSS property is called "vertical-align" and can take the values "top", "bottom" or "middle".
To align the text in table cells at the top, you can write the following:
The beauty of this solution, compared to the solution with valign="top", is that you can define the CSS rule once and centrally in a CSS stylesheet without having to edit each cell of your table(s) individually. This also helps you to separate your content from your style instructions.
2023-11-02 at 01:39