A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: quick CSS question regarding margins in tables

  1. #1
    Running Plodding & Limping SpockBert's Avatar
    Join Date
    Jun 2002
    Location
    London
    Posts
    593

    quick CSS question regarding margins in tables

    If have a table cell and I want everything within that to have a margin of 20.

    Now I thought in my definition for that table cell, I put something like:

    td.mytablecell{
    height:600
    width:440;
    background-image:url('images/curvesMiddle440.gif');
    background-repeat:repeat-y;
    vertical-align:top;
    margin:20;
    }

    then in html itself:

    <td class="mytablecell"> <p>my text here blah blah blah</p></td>

    but its not working

    Only way I can set the margins of that table is to put the margin parameter within the <p> definition.

    p {
    font:12px arial;
    margin:20;
    }

    That seem right?

  2. #2
    Goodbye...
    Join Date
    Aug 2003
    Posts
    661
    Hmmm, this question doesn't seem to belong here.

    Though I doubt this will make a difference, make your margin: 20px;

    Another thing you could try would be placing your paragraph within a <div > and adding the margin to that... also, check your padding values, they may be affecting it.

  3. #3
    Senior Member
    Join Date
    Mar 2005
    Posts
    147
    If you want only the left margin to be 20, then put

    Code:
    margin-left: 20px;
    but if you want all margins 20px

    Code:
    margin: 20px 20px 20px 20px
    that is, top margin, then right margin, then bottom margin then left margin.
    joechilds@imap.cc
    www.blackliquor.co.uk

  4. #4
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    I don't think table cells can have margins applied.

    You could maybe achieve the effect you want by applying styles to both the td and the child p tag,

    Code:
    td.mytablecell {
      width: 440px; height: 600px;
      vertical-align: top;
    }
    
    td.mytablecell p {
      background: url(images/curvesMiddle440.gif) repeat-y;
      margin: 20px;
    }

  5. #5
    Senior Member
    Join Date
    Mar 2005
    Posts
    147
    They can. Just use

    Code:
    table, td, tr, th {
    margin-left: 20px;
    }
    for left margin only, or

    Code:
    table, td, tr, th (
    margin: 20px 20px 20px 20px;
    }
    for all margins.

    No probs, problem fixed
    joechilds@imap.cc
    www.blackliquor.co.uk

  6. #6
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    No, they can't (unless you change their display property so they no longer behave as table cells).

    Internal table elements generate rectangular boxes with content and borders. Cells have padding as well. Internal table elements do not have margins.
    From section 17.5 Visual layout of table contents - http://www.w3.org/TR/CSS21/tables.html

  7. #7
    Senior Member
    Join Date
    Mar 2005
    Posts
    147
    Okey doke lol. My bad
    joechilds@imap.cc
    www.blackliquor.co.uk

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center