tags:

views:

112

answers:

2

I would like to have all cells in a with "vertical-align:top" style. For technical reasons outside my control, I cannot define a new class, or change the stylesheet at all; nor can I set "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, not of individual cells inside it. Is there any other alternative that I'm missing?

+1  A: 

No, as far as I can see there is no way to do this without some form of access to either the td itself or a style sheet.

Can you apply a workaround like this one? It's not pretty and invalid according to the W3C, but should nevertheless work in all browsers:

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

Set the "classic" HTML valign attribute on the table. The value will be inherited by the cells.

<table valign="top">
  …

See Tables, Table formatting by visual user agents, Horizontal and vertical alignment in the HTML 4 spec.

Dominic Cooney