Author Topic: HTML in cell contents  (Read 2191 times)

Lafrog

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
HTML in cell contents
« on: July 03, 2015, 01:56:20 PM »
Hi all,

I want to add a table in a cell but how do I set the text to comply with the text style I gave to that cell?

TIA
Michel

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 5428
    • View Profile
Re: HTML in cell contents
« Reply #1 on: July 05, 2015, 10:38:36 PM »
Ah, this is a failing of Internet Explorer.  It turns out that while most HTML elements inherit the styles of their parent, tables do not (at least not in the mode the TD is stuck in).  Unfortunately you just have to manually set those styles yourself.

For example:

<table border=1 style="color: white; font-size: 36pt; font-family: Arial;">
<tr>
<td>This is a table</td>
</tr>
</table>


That's not bad, but a bit of a hassle, since when you change the text styles in the cell, you'll also have to change them within the HTML.  There's a way to work around the IE bug:

<table border=1 style="
color: expression(this.parentNode.currentStyle.color);
  font-style: expression(this.parentNode.currentStyle.fontStyle);
  font-size: expression(this.parentNode.currentStyle.fontSize);
  font-variant: expression(this.parentNode.currentStyle.fontVariant);
  font-weight: expression(this.parentNode.currentStyle.fontWeight);
  line-height: expression(this.parentNode.currentStyle.lineHeight);
  text-decoration: expression(this.parentNode.currentStyle.textDecoration);
  white-space: expression(this.parentNode.currentStyle.whiteSpace);
">
<tr>
<td>This is a table</td>
</tr>
</table>


You don't have to specify all of those if you don't want, but it's easier to just cut-and-paste that block of styles.  This work around causes the table to use the same styles as its parent node.  So it will "inherit" the styles from the cell.  This is a better solution, since it gives the behavior you expect.  It used to be available from within the TD, but I receive lots of error reports due to it.  There's nothing wrong with it, as far as I can tell, but IE still has trouble with it from time to time.

Lafrog

  • Jr. Member
  • **
  • Posts: 79
    • View Profile
Re: HTML in cell contents
« Reply #2 on: July 06, 2015, 11:36:32 AM »
Thanks, I will give this a go.

Michel