Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

internet explorer not honouring table cell width

Status
Not open for further replies.

devlann

Programmer
Feb 12, 2008
2
CA
the following bit of html is meant to show a check box with some text immediatly to it's right. in firefox, opera, and safari, it works. in internet explorer there is a bunch of white space added to the cell the check box is in. is there any way to get internet explorer to behave the same as the other browsers?

Code:
<html>
  <body>
    <table border="1">
      <tr>
        <td colspan="2" nowrap="true">a whole bunch of text to make a wide column</td>
      </tr>
      <tr>
        <td style="width: 1px;"><input id="checkbox" type="checkbox" /></td>
        <td>some text</td>
      </tr>
    </table>
  </body>
</html>
 
Tables are not the best way to achieve that, because tables were designed to expand to hold enough content. You could try adding [tt]table-layout: fixed;[/tt] to the table style. That will force the table to have fixed widths on columns. However, 1px for the checkbox will be simply too small then.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Keep it simple. To have text immediately right to a checkbox, simply use the input tag in it's complete form:
Code:
<html>
  <body>
    <input id="checkbox" type="checkbox">some text</input>
  </body>
</html>

You're using the XHTML notation of /> for empty elements. That's only recommended for tags, which don't have a corresponding closing tag, like <br>, which should be used as <br /> in XHTML.

You're not even defining a DOCTYPE, which is the error in the first place. Depending on that different browsers will interpret the same html in different ways.

While your html code may just be a simplified posting example, times where those meta html info was optional and you could easily work with a simple text editor are over. And times where you would lay out a page with html tables are over even longer.

Bye, Olaf.
 
The 'correct' form would be to use a label tag with the input.

Code:
<input type="checkbox" id="box1" /><label for="box1">Some text</label>

Or even

Code:
<label><input type="checkbox" id="box1" /> Some Text</label>


Building successful websites with a text editor since 1997


--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
i would much prefer not to use a table do to this, but unfortunately i'm stuck due to legacy issues and need the table structure. it looks like its time to do some refactoring :)

using <input /> or <input></input> makes no difference.

the code is being pulled from a fully formed html page with a DOCTYPE and everything else. that page has the exact same issues. and the page also encloses the text beside the checkbox in a <label>.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
in fact input is an empty tag, I thought wrong. Well additional to style = "table-layout:fixed;", you'll perhaps want some <col> tags.

Bye, Olaf.
 
I think it would help to see the page in it's entirety.

--
Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top