开发者

Chrome put content in <td> on a new line. FF Doesn't

I'm creating an overview with data from a database. But in Chrome (and Safari and Opera) The <td></td> content starts on a new line, while Firefox and IE(8) display it on the same line.

Name Event: <开发者_运维问答;td>'.mysql_real_escape_string(mysql_result($result, $i,"event_title")).'</td>
Max # Persons: <td>'.mysql_real_escape_string(mysql_result($result, $i,"max_participants")).'</td>
Total Guests: <td>'.mysql_real_escape_string($row['total_guests']).'</td>    
Status Event: <td>'.$status.'</td>

Example:

Chrome:

Name Event:

Wedding

FireFox:

Name Event: Wedding

The same happens when I end every line with a <br> or <br/>

Is there a (easy) workaround to fix this?


This is invalid HTML. How it will be rendered is totally undefined.

Inside a table, any text content must be inside <td> (or <th>) tags.

You need to put the labels into <td> tags as well, and wrap everything in <tr>s.

A complete mini-structure for a table would look like this:

<table>
 <tr>
  <td>Name Event: </td><td>...</td>
  <td>Max # Persons:</td><td>...</td>
  <td>Total Guests:</td><td>...</td>
  <td>Status Event:</td><td>...</td>
 </tr>
</table>


Table structure should be like so:

<table>
  <tr>
    <td>Name Event: </td><td>'.mysql_real_escape_string(mysql_result($result, $i,"event_title")).'</td>
    <td>Max # Persons: </td><td>'.mysql_real_escape_string(mysql_result($result, $i,"max_participants")).'</td>
    <td>Total Guests: </td><td>'.mysql_real_escape_string($row['total_guests']).'</td>    
    <td>Status Event: </td><td>'.$status.'</td>
  </tr>
</table>


The reason it looks different in different browsers is that your HTML is invalid, so there's no guaranteed result - each browser will try to do their best to work out what you mean, but you can't be sure they'll come to the same conclusion.

<td> is supposed to be part of an HTML table. You should either restructure it so that everything is in correctly formatted <table>, <tr> and <td> tags, or switch to using a different type of tag (there are several that could be suitable).

Either way, if you structure it correctly, it will render the same in different browsers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜