div width in table cell adding extra space.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MattB

    div width in table cell adding extra space.

    Hello please help,

    I have a table cell with a div in it. The div has a width of 300px.
    but when it is rendered it puts extra space into the table cell.

    Here's the style

    <style>
    #treecontainer
    {
    HEIGHT: 100%;
    BACKGROUND: #ffffff;
    overflow: hidden;
    BORDER-TOP: 1px solid;
    BORDER-BOTTOM: 1px solid;
    BORDER-LEFT: 2px solid;
    BORDER-RIGHT: 2px solid;
    WIDTH: 230px;
    DISPLAY: inline;
    position: static;
    }
    </style>

    and here is the HTML fragment...

    <table border="1" cellspacing="0" cellpadding="0"
    style="width:25 0px;">
    <tr height="10">
    <td></td>
    <td><img src="./images/top-lf-lb.gif" border="0" /></td>
    <td width="100%" background="./images/top-repeat-strip-lb.gif"></td>
    <td><img src="./images/top-rt-lb.gif" border="0" /></td>
    </tr>
    <tr>
    <td></td>
    <td colspan="3" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px;
    PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
    <div id="treecontain er" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px;
    PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
    </div>
    </td>
    </tr>
    <tr height="10" id="r3">
    <td width="3" valign="top">
    </td>
    <td><img src="./images/bottom-lf-lb.gif" border="0"></td>
    <td width="100%" background="./images/bottom-repeat-strip-lb.gif">
    <img src="./images/sp.gif" border="0"></td>
    <td><img src="./images/bottom-rt-lb.gif" border="0"></td>
    </tr>
    </table>
  • Brian

    #2
    Re: div width in table cell adding extra space.

    MattB wrote:
    [color=blue]
    > Hello please help,[/color]

    Not until you learn not to multi-post.



    --
    Brian (remove ".invalid" to email me)

    Comment

    • marathon

      #3
      Re: div width in table cell adding extra space.

      On 28 Jul 2004 08:20:49 -0700, MattB in comp.infosystem s.www.authoring.html wrote:[color=blue]
      >Hello please help,[/color]
      [color=blue]
      >I have a table cell with a div in it. The div has a width of 300px.
      >but when it is rendered it puts extra space into the table cell.[/color]

      The problem is - You shouldn't put divs into tables! Tables into divs
      only.

      --
      ATTENTION
      This room is fullfilled mit special electronische equippment.
      Fingergrabbing and pressing the cnoeppkes from the computers is
      allowed for die experts only! So all the "lefthander s" stay away
      and do not disturben the brainstorming von here working
      intelligencies. Otherwise you will be out thrown and kicked
      anderswhere! Also: please keep still and only watchen
      astaunished the blinkenlights.

      Comment

      • Steve Pugh

        #4
        Re: div width in table cell adding extra space.

        marathon <M@linux.ca> wrote:
        [color=blue]
        >On 28 Jul 2004 08:20:49 -0700, MattB in comp.infosystem s.www.authoring.html wrote:[color=green]
        >>Hello please help,[/color]
        >[color=green]
        >>I have a table cell with a div in it. The div has a width of 300px.
        >>but when it is rendered it puts extra space into the table cell.[/color]
        >
        >The problem is - You shouldn't put divs into tables! Tables into divs
        >only.[/color]

        Why?
        If you mean that you shouldn't use <table><div> directly then you are
        correct, but <td><div> is permitted and might be justified for some
        complex tabular data.

        Steve

        --
        "My theories appal you, my heresies outrage you,
        I never answer letters and you don't like my tie." - The Doctor

        Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

        Comment

        • marathon

          #5
          Re: div width in table cell adding extra space.

          On Thu, 29 Jul 2004 07:57:17 +0100, Steve Pugh in comp.infosystem s.www.authoring.html wrote:[color=blue]
          >marathon <M@linux.ca> wrote:[/color]
          [color=blue][color=green]
          >>On 28 Jul 2004 08:20:49 -0700, MattB in comp.infosystem s.www.authoring.html wrote:[color=darkred]
          >>>Hello please help,[/color]
          >>[color=darkred]
          >>>I have a table cell with a div in it. The div has a width of 300px.
          >>>but when it is rendered it puts extra space into the table cell.[/color]
          >>
          >>The problem is - You shouldn't put divs into tables! Tables into divs
          >>only.[/color][/color]
          [color=blue]
          >Why?
          >If you mean that you shouldn't use <table><div> directly then you are
          >correct, but <td><div> is permitted and might be justified for some
          >complex tabular data.[/color]

          Why? Because they cause issues, similiar to what the OP is experiencing.
          As soon as one put's a div in table, then don't be surprised if one has
          problems. <shrug>

          --
          ATTENTION
          This room is fullfilled mit special electronische equippment.
          Fingergrabbing and pressing the cnoeppkes from the computers is
          allowed for die experts only! So all the "lefthander s" stay away
          and do not disturben the brainstorming von here working
          intelligencies. Otherwise you will be out thrown and kicked
          anderswhere! Also: please keep still and only watchen
          astaunished the blinkenlights.

          Comment

          • Brian

            #6
            Re: div width in table cell adding extra space.

            marathon wrote:
            [color=blue]
            > Steve Pugh wrote:
            >[color=green]
            >> marathon <M@linux.ca> wrote:[/color]
            >[color=green][color=darkred]
            >>> The problem is - You shouldn't put divs into tables! Tables into
            >>> divs only.[/color][/color]
            >[color=green]
            >> Why?[/color]
            >
            > Why? Because they cause issues, similiar to what the OP is
            > experiencing. As soon as one put's a div in table, then don't be
            > surprised if one has problems. <shrug>[/color]

            Are you just making this up as you go along? How does putting a <div>
            inside a <td> cause problems?

            --
            Brian (remove ".invalid" to email me)

            Comment

            • Steve Pugh

              #7
              Re: div width in table cell adding extra space.

              marathon <M@linux.ca> wrote:[color=blue]
              >Steve Pugh <steve@pugh.net > wrote:[color=green]
              >>marathon <M@linux.ca> wrote:
              >>[color=darkred]
              >>>The problem is - You shouldn't put divs into tables! Tables into divs
              >>>only.[/color][/color]
              >[color=green]
              >>Why?
              >>If you mean that you shouldn't use <table><div> directly then you are
              >>correct, but <td><div> is permitted and might be justified for some
              >>complex tabular data.[/color]
              >
              >Why? Because they cause issues, similiar to what the OP is experiencing.[/color]

              As far as I can see the OP's problem is caused by IE's peculiar
              handling of a td with colspan>1 and _any_ contents with a width set in
              CSS. (Probably compounded by triggering quirks mode, but without a URL
              we can't really tell.)

              In other words the problem would be the same if <p> or <ol> or <table>
              was used instead of <div>. Do you recommend not using them inside
              tables as well?
              [color=blue]
              >As soon as one put's a div in table, then don't be surprised if one has
              >problems. <shrug>[/color]

              <shrug> indeed. <td><div>...</div></td> can be used to solve a lot of
              problems in older browsers (e.g. workarounds for IE's box model bugs).

              Steve

              --
              "My theories appal you, my heresies outrage you,
              I never answer letters and you don't like my tie." - The Doctor

              Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

              Comment

              • MattB

                #8
                Re: div width in table cell adding extra space.

                The solution found, not to say it is the only one or the right one,
                etc. but as I only know the css styles I really need and only try out
                various ones I think might sort out these little fluxes in display.

                first setup other tags to act like tables

                <style>
                DIV {
                TABLE-LAYOUT: fixed; BORDER-COLLAPSE: collapse;displa y: table;
                }
                P {
                PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN:
                0px; PADDING-TOP: 0px; display: table-row;
                }
                HTML P {
                MARGIN-BOTTOM: -1px;
                }
                SPAN {
                BORDER-RIGHT: #000000 0px solid; PADDING-RIGHT: 0px; BORDER-TOP:
                #000000 0px solid; PADDING-LEFT: 0px;
                PADDING-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: #000000 0px solid;
                WIDTH: 30px; PADDING-TOP: 0px;
                BORDER-BOTTOM: #000000 0px solid; BACKGROUND-COLOR: #ffffff; display:
                table-cell;
                }
                HTML SPAN {
                DISPLAY: inline-block; MARGIN-RIGHT: 0px
                }
                </style>

                then create a table like structure with your div in it...
                I never worked out how to mimick the background image of a table cell
                in a <span tag acting like a table cell with a

                <div>
                <p><span><tab le border="0" cellpadding="0" cellspacing="0"
                height="10px" width="224px">< tr><td><IMG src="../images/top-lf-lb.gif"
                border=0 ></td><td background=../images/top-repeat-strip-lb.gif ><IMG
                src="../images/sp.gif" border="0" width="200px" height="1px"
                /></td><td><IMG src="../images/top-rt-lb.gif" border=0[color=blue]
                ></td></tr></table></SPAN></P>[/color]
                <p>
                <span>
                <div id="treecontain er" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px;
                PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px;WIDTH: 230px;
                "/>
                </span>
                </p>
                <p ><span><table border="0" cellpadding="0" cellspacing="0"
                height="10px" width="224px">< tr><td colspan="3"><IM G
                src="../images/bottom-lf-lb.gif" border=0 ></td><td
                background="../images/bottom-repeat-strip-lb.gif"><IMG
                src="../images/sp.gif" border="0" width="200px" height="1px"
                /></td><td><IMG src="../images/bottom-rt-lb.gif" border=0 ></SPAN></P>
                </DIV>


                Steve Pugh <steve@pugh.net > wrote in message news:<as7hg015f jas7jdhdju7ci89 f5mvtor7oq@4ax. com>...[color=blue]
                > marathon <M@linux.ca> wrote:
                >[color=green]
                > >On 28 Jul 2004 08:20:49 -0700, MattB in comp.infosystem s.www.authoring.html wrote:[color=darkred]
                > >>Hello please help,[/color][/color]
                >[color=green][color=darkred]
                > >>I have a table cell with a div in it. The div has a width of 300px.
                > >>but when it is rendered it puts extra space into the table cell.[/color]
                > >
                > >The problem is - You shouldn't put divs into tables! Tables into divs
                > >only.[/color]
                >
                > Why?
                > If you mean that you shouldn't use <table><div> directly then you are
                > correct, but <td><div> is permitted and might be justified for some
                > complex tabular data.
                >
                > Steve[/color]

                Comment

                • marathon

                  #9
                  Re: div width in table cell adding extra space.

                  On Thu, 29 Jul 2004 10:18:39 -0400, Brian in
                  comp.infosystem s.www.authoring.html wrote:
                  [color=blue]
                  >marathon wrote:[/color]
                  [color=blue][color=green]
                  >> Steve Pugh wrote:
                  >>[color=darkred]
                  >>> marathon <M@linux.ca> wrote:[/color]
                  >>[color=darkred]
                  >>>> The problem is - You shouldn't put divs into tables! Tables into
                  >>>> divs only.[/color]
                  >>[color=darkred]
                  >>> Why?[/color]
                  >>
                  >> Why? Because they cause issues, similiar to what the OP is
                  >> experiencing. As soon as one put's a div in table, then don't be
                  >> surprised if one has problems. <shrug>[/color][/color]
                  [color=blue]
                  >Are you just making this up as you go along? How does putting a <div>
                  >inside a <td> cause problems?[/color]

                  Brian, I'm definitely not making this up as I go along, thank-you. I
                  think you appear to think you're talking to a grade school child.
                  However that aside:

                  I'm more of a programmer than a designer. However I do distinctly
                  remember the more esteemed members of the Dreamweaver Design community
                  saying that Divs into tables was problematic. Tables into browsers
                  apparently are better supported across most browser versions.

                  I'll quote from one particular HTML guru from the Macromedia Dreamweaver
                  site:


                  "Never put layers in tables. Netscape 4x, and Macintosh browsers
                  will not properly render layers in tables. If you are having
                  positioning problems with layers but only in certain browsers, this
                  is the first thing to look for. The solution would be to move the
                  layer(s)'s code out of the table, and re-insert it immediately above
                  the end <body> tag (that's the beauty of an absolutely positioned
                  page element - its position on the page is not dependent on its
                  position in the code)."

                  The foregoing came from this URL;

                  <http://www.thepattysit e.com/layer_laws.cfm>

                  There's also other relevant threads here;

                  <http://groups.google.c a/groups?hl=en&lr =&ie=UTF-8&safe=off&c2co ff=1&q=divs+int o+tables&btnG=S earch&meta=grou p%3Dmacromedia. dreamweaver.*>

                  or smaller URL;

                  <http://tinyurl.com/5u5fp>

                  --
                  ATTENTION
                  This room is fullfilled mit special electronische equippment.
                  Fingergrabbing and pressing the cnoeppkes from the computers is
                  allowed for die experts only! So all the "lefthander s" stay away
                  and do not disturben the brainstorming von here working
                  intelligencies. Otherwise you will be out thrown and kicked
                  anderswhere! Also: please keep still and only watchen
                  astaunished the blinkenlights.

                  Comment

                  • Brian

                    #10
                    Re: div width in table cell adding extra space.

                    marathon wrote:
                    [color=blue][color=green]
                    >> marathon wrote:[/color]
                    >[color=green][color=darkred]
                    >>> As soon as one put's a div in table, then don't be surprised if
                    >>> one has problems. <shrug>[/color][/color]
                    >
                    > I'm more of a programmer than a designer.[/color]

                    If HTML is not your forte, then, and with all due respect, you shouldn't
                    be making claims about how HTML works in browsers.
                    [color=blue]
                    > However I do distinctly remember the more esteemed members of the
                    > Dreamweaver Design community[/color]

                    Although a few CIWAH regulars use Dreamweaver, citing the Dreamweaver
                    Design community is not going to win you points here. For one thing,
                    Dreamweaver is not a browser.
                    [color=blue]
                    > saying that Divs into tables was problematic.[/color]

                    Unless you can present a test case where a <div> placed inside a <td>
                    causes some special problems, this claim is baseless.
                    [color=blue]
                    > Tables into browsers apparently are better supported across most
                    > browser versions.[/color]

                    Not sure what you meant here. Perhaps "Tables into <td> elements"?
                    [color=blue]
                    > I'll quote from one particular HTML guru from the Macromedia
                    > Dreamweaver site:
                    >
                    > "Never put layers in tables. Netscape 4x, and Macintosh browsers will
                    > not properly render layers in tables.[/color]

                    <layer> != <div>

                    So this "HTML guru" appears to be talking about a Netscape proprietary
                    element that is unrelated to the <div> element. For some reason, the two
                    get confused by those unfamiliar with HTML, as you have done.

                    --
                    Brian (remove ".invalid" to email me)

                    Comment

                    • Stephen Poley

                      #11
                      Re: div width in table cell adding extra space.

                      On Fri, 30 Jul 2004 12:07:31 -0400, marathon <M@linux.ca> wrote:
                      [color=blue][color=green]
                      >>Are you just making this up as you go along? How does putting a <div>
                      >>inside a <td> cause problems?[/color]
                      >
                      >Brian, I'm definitely not making this up as I go along, thank-you. I
                      >think you appear to think you're talking to a grade school child.
                      >However that aside:
                      >
                      >I'm more of a programmer than a designer. However I do distinctly
                      >remember the more esteemed members of the Dreamweaver Design community
                      >saying that Divs into tables was problematic. Tables into browsers
                      >apparently are better supported across most browser versions.
                      >
                      >I'll quote from one particular HTML guru from the Macromedia Dreamweaver
                      >site:
                      >
                      > "Never put layers in tables. Netscape 4x, and Macintosh browsers
                      > will not properly render layers in tables.[/color]

                      Are you talking about DIVs or LAYERs? LAYER is a Netscape 3/4
                      proprietary construct and forms no part of the HTML specification. It is
                      entirely possible that layers inside tables give problems, but that is
                      of no importance to anyone nowadays.

                      --
                      Stephen Poley


                      Comment

                      • marathon

                        #12
                        Re: div width in table cell adding extra space.

                        On Fri, 30 Jul 2004 19:55:26 +0200, Stephen Poley in comp.infosystem s.www.authoring.html wrote:[color=blue]
                        >On Fri, 30 Jul 2004 12:07:31 -0400, marathon <M@linux.ca> wrote:[/color]
                        [color=blue][color=green]
                        >>I'll quote from one particular HTML guru from the Macromedia Dreamweaver
                        >>site:
                        >>
                        >> "Never put layers in tables. Netscape 4x, and Macintosh browsers
                        >> will not properly render layers in tables.[/color][/color]
                        [color=blue]
                        >Are you talking about DIVs or LAYERs? LAYER is a Netscape 3/4
                        >proprietary construct and forms no part of the HTML specification. It is
                        >entirely possible that layers inside tables give problems, but that is
                        >of no importance to anyone nowadays.[/color]

                        No, some HTML Visual Editors refer to divs as "layers".


                        --
                        ATTENTION
                        This room is fullfilled mit special electronische equippment.
                        Fingergrabbing and pressing the cnoeppkes from the computers is
                        allowed for die experts only! So all the "lefthander s" stay away
                        and do not disturben the brainstorming von here working
                        intelligencies. Otherwise you will be out thrown and kicked
                        anderswhere! Also: please keep still and only watchen
                        astaunished the blinkenlights.

                        Comment

                        • marathon

                          #13
                          Re: div width in table cell adding extra space.

                          On Fri, 30 Jul 2004 13:29:50 -0400, Brian in comp.infosystem s.www.authoring.html wrote:[color=blue]
                          >marathon wrote:[/color]
                          [color=blue][color=green][color=darkred]
                          >>> marathon wrote:[/color]
                          >>[color=darkred]
                          >>>> As soon as one put's a div in table, then don't be surprised if
                          >>>> one has problems. <shrug>[/color]
                          >>
                          >> I'm more of a programmer than a designer.[/color][/color]
                          [color=blue]
                          >If HTML is not your forte, then, and with all due respect, you shouldn't
                          >be making claims about how HTML works in browsers.[/color]

                          Oh OK.
                          [color=blue][color=green]
                          >> However I do distinctly remember the more esteemed members of the
                          >> Dreamweaver Design community[/color][/color]
                          [color=blue]
                          >Although a few CIWAH regulars use Dreamweaver, citing the Dreamweaver
                          >Design community is not going to win you points here. For one thing,
                          >Dreamweaver is not a browser.[/color]

                          That's like saying good programmers don't use IDEs, simply a misdiretion
                          and an invalid point.
                          [color=blue][color=green]
                          >> saying that Divs into tables was problematic.[/color][/color]
                          [color=blue]
                          >Unless you can present a test case where a <div> placed inside a <td>
                          >causes some special problems, this claim is baseless.[/color]

                          My friend, I presented you with a plethora of examples.
                          [color=blue][color=green]
                          >> Tables into browsers apparently are better supported across most
                          >> browser versions.[/color][/color]
                          [color=blue]
                          >Not sure what you meant here. Perhaps "Tables into <td> elements"?[/color]

                          No, tables into layers...
                          [color=blue][color=green]
                          >> I'll quote from one particular HTML guru from the Macromedia
                          >> Dreamweaver site:
                          >>
                          >> "Never put layers in tables. Netscape 4x, and Macintosh browsers will
                          >> not properly render layers in tables.[/color][/color]
                          [color=blue]
                          ><layer> != <div>[/color]

                          Actually layers _ARE EQUAL_ to divs in the HTML sense.
                          [color=blue]
                          >So this "HTML guru" appears to be talking about a Netscape proprietary
                          >element that is unrelated to the <div> element. For some reason, the two
                          >get confused by those unfamiliar with HTML, as you have done.[/color]

                          What that HTML guru is saying (as are many others), is that inserting
                          divs into tables isn't supported cross browser.

                          --
                          ATTENTION
                          This room is fullfilled mit special electronische equippment.
                          Fingergrabbing and pressing the cnoeppkes from the computers is
                          allowed for die experts only! So all the "lefthander s" stay away
                          and do not disturben the brainstorming von here working
                          intelligencies. Otherwise you will be out thrown and kicked
                          anderswhere! Also: please keep still and only watchen
                          astaunished the blinkenlights.

                          Comment

                          • Stephen Poley

                            #14
                            Re: div width in table cell adding extra space.

                            On Fri, 30 Jul 2004 19:36:11 -0400, marathon <M@linux.ca> wrote:
                            [color=blue]
                            >On Fri, 30 Jul 2004 19:55:26 +0200, Stephen Poley in comp.infosystem s.www.authoring.html wrote:[color=green]
                            >>On Fri, 30 Jul 2004 12:07:31 -0400, marathon <M@linux.ca> wrote:[/color]
                            >[color=green][color=darkred]
                            >>>I'll quote from one particular HTML guru from the Macromedia Dreamweaver
                            >>>site:
                            >>>
                            >>> "Never put layers in tables. Netscape 4x, and Macintosh browsers
                            >>> will not properly render layers in tables.[/color][/color]
                            >[color=green]
                            >>Are you talking about DIVs or LAYERs? LAYER is a Netscape 3/4
                            >>proprietary construct and forms no part of the HTML specification. It is
                            >>entirely possible that layers inside tables give problems, but that is
                            >>of no importance to anyone nowadays.[/color]
                            >
                            >No, some HTML Visual Editors refer to divs as "layers".[/color]


                            The first page you quoted, http://www.thepattysite.com/layer_laws.cfm,
                            says in its very first paragraph that a layer is an
                            *absolutely-positioned* div. It seems to me that you are out of your
                            depth and should do a bit more reading and experimentation before you
                            come out with sweeping statements such as "you shouldn't put divs into
                            tables".

                            Incidentally that page is pretty unimpressive, as it mixes up tags with
                            elements, makes confusing use of the term 'inline' (in CSS terms inline
                            elements cannot be absolutely positioned), and generally gives the
                            impression that the author hasn't read the HTML and CSS specs recently,
                            if at all.

                            --
                            Stephen Poley


                            Comment

                            • Spartanicus

                              #15
                              Re: div width in table cell adding extra space.

                              Stephen Poley <sbpoleySpicedH amTrap@xs4all.n l> wrote:
                              [color=blue]
                              >in CSS terms inline elements cannot be absolutely positioned[/color]

                              Incorrect.

                              --
                              Spartanicus

                              Comment

                              Working...