Forum Moderators: not2easy
<!--[if gte IE 6]> <link href="re-style.css" rel="stylesheet" type="text/css"> <![ENDIF]-->
<!--[if lt IE 6]> <link href="re-iehack5.css" rel="stylesheet" type="text/css"> <![ENDIF]-->
</head>
How to do such CONDITIONAL STATEMENT when I would like to direct change table TAG value like HEIGHT?
See sample in table:
<tr>
<td height="27" align="center" valign="middle" bgcolor="#CED4EC"> </td>
</tr>
I need the following:
In Mozilla will be height 26 and in IE will be height 27
Need help.
How to do such CONDITIONAL STATEMENT when I would like to direct change table TAG value like HEIGHT?
# This can be done, but starts to get very hard to read. I really do suggest removing your style rules into an embedded style sheet (in the head section of the page) or into an external style sheet to make this easier to manage and avoid duplication
# Maybe a typo? - height needs a unit of measurement eg height="27em"
This achieves a "direct change" of the complete code for the table cell which makes it more readable. Experiment to just change height if you wish. The first conditional comment sends to non-ie, the second to IE (all versions)
<tr>
<!--[if !IE]><!-->
<td height="26em" align="center" valign="middle" bgcolor="#CED4EC"> </td><!--<![endif]-->
<!--[if IE]>
<td height="27em" align="center" valign="middle" bgcolor="#CED4EC"> </td><!--<![endif]-->
<![endif]-->
</tr>
Otherwise, if you have a field that allows you to change your sample:
<tr>
<td height="27" align="center" valign="middle" bgcolor="#CED4EC"> </td>
</tr>
Then just replace it completely with the code example:
<tr>
<!--[if !IE]><!-->
<td height="26em" align="center" valign="middle" bgcolor="#CED4EC"> </td><!--<![endif]-->
<!--[if IE]>
<td height="27em" align="center" valign="middle" bgcolor="#CED4EC"> </td><!--<![endif]-->
<![endif]-->
</tr>
Do not know why but strict old validation like [validator.w3.org...] show 5 erros for this solved problem.
This illustrates the importance of validating!
First is my mistake in the conditional comments. Validate, validate, validate ;)
Second, as the forum posting guides say, provide a doctype when you first post, and try to provide some information to make resolving the problems faster and easier.
But now you've said you're coding strict, I'm guessing the other two errors are:
# there is no attribute "HEIGHT".
And
# there is no attribute "BGCOLOR".
If my guess is right, that's because they're not permitted with a strict doctype. As suggested above, consider moving your style rules into an embedded or external style sheet (and becoming familiar with some of the rules so you can use css for styling).
Until then, this validated - before I copied it to here ;)
<tr>
<!--[if !IE]><!-->
<td align="center" valign="middle" style="height:26em;background-color:#CED4EC"> </td>
<!--<![endif]--><!--[if IE]>
<td align="center" valign="middle" style="height:27em;background-color:#CED4EC"> </td>
<![endif]-->
</tr>
Happy validating!