I have a script that has tables embedded inside php. When I change the td width in a table, it shows up in internet explorer, but it doesnt show up in firefox. I am having to do

<td width='230' .....

because the "" will throw off the PHP. I am curious what I need to do to get firefox and IE to both recognize the table width, because only IE is doing it now.

Thanks.

Dani AI

Generated

A few likely causes and fixes for “IE shows the td width but Firefox does not” that go beyond the short suggestions already posted by and .

Browsers use different table-layout rules unless you constrain them. Firefox follows the CSS table algorithm and will grow cells to fit content unless the table or columns are constrained. Using a fixed layout and defining column widths via CSS (or a colgroup) gives predictable, cross-browser results and avoids relying on deprecated presentational attributes.

A practical pattern that works reliably:

<style>
.mytable { table-layout: fixed; width: 700px; border-collapse: collapse; }
.mytable col.col1 { width: 230px; }
.mytable td { box-sizing: border-box; padding: 6px; overflow-wrap: break-word; }
</style>

<table class="mytable">
  <colgroup>
    <col class="col1">
    <col>
    <col>
  </colgroup>
  <tr><td>First column</td><td>Second</td><td>Third</td></tr>
</table>

For generating HTML from PHP without constant escaping (you mentioned quote problems), use a heredoc/nowdoc or close PHP to emit the HTML block — cleaner and less error-prone than mixing lots of escaped quotes.

Troubleshooting checklist: inspect the computed widths in Firefox devtools to see what’s forcing expansion; ensure a valid DOCTYPE (no quirks mode); watch for unbreakable strings or large images (use overflow-wrap / max-width); and prefer CSS widths over legacy attributes for consistent behavior across modern browsers. Combining the fixed table layout plus cleaner PHP output will make the widths reliable in both Firefox and IE.

Recommended Answers

All 2 Replies

You may try inline CSS

To agree with peter, CSS is usually the way to go.

Of course, since you're using php, you could always use a backslash in front of your double quotes (like so: \") so that PHP will recognize it as part of your HTML, not your PHP

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.