How to set vertical alignment for all cells in a table by setting the style of a table element?

I would like to have all the cells in the style of "vertical-align: top". For technical reasons beyond my control, I cannot define a new class or modify the stylesheet at all; and I can’t set the β€œstyle” for individual cells or even rows. All I can do is set the "style" attribute of the <table> element itself.

Using <table style="vertical-align:top"> fails - apparently, it sets the alignment of the table within its own context, and not the individual cells inside it. Is there any other alternative that I am missing?

+4
source share
4 answers

You can use css

 table tr td { vertical-align: top; } 
+3
source

No, as far as I can see, there is no way to do this without any access to td itself or the stylesheet.

Can a workaround like this be applied? This is not very and invalid according to the W3C, but should still work in all browsers:

 <style type='text/css'> table.topalign td { vertical-align: top } </style> <table class="topalign"> .... 
+2
source

Set the "classic" HTML option attribute in the table. The value will be inherited by the cells.

 <table valign="top"> … 

See Tables, formatting tables with visual user agents, horizontal and vertical alignment in the HTML 4 specification.

-1
source

table tr {valign: top} In this case, you do not need to use the css class.

-1
source

Source: https://habr.com/ru/post/1300545/


All Articles