SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Explain Best Padding Techniques to Me

  1. #1
    SitePoint Addict
    Join Date
    May 2006
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Explain Best Padding Techniques to Me

    Hi Guys

    Re:

    http://www.highlycreative.co.uk/test...uts/test17.htm

    I've just tried adding 10px padding to ColumnLeft, but I've found this expands the width of the div and pushes ColumnRight below it.

    In general, what padding techniques are best? Should I be padding the div, or should I be padding the h1 and p tags within the div? I need to get an idea of best practice.

    Many thanks

  2. #2
    SitePoint Addict
    Join Date
    May 2006
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would I be right in saying that the correct technique is to add a container div around the div I want to pad, then add the width property to the container div, and have just the padding on the div I want padded.

    Thanks

  3. #3
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    1,090
    Mentioned
    16 Post(s)
    Tagged
    2 Thread(s)
    At least a couple of choices:

    The css box model says that the width of a container is the sum of the declared width plus any padding. So, you can keep the 10px padding but you need to reduce the width value to 580px.

    Another method is to add left and right padding or margins to the contained text.

  4. #4
    It's all Geek to me silver trophybronze trophy
    SitePoint Award Recipient ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, Australia
    Posts
    20,303
    Mentioned
    225 Post(s)
    Tagged
    3 Thread(s)
    The easiest way is to put a div inside the divs with a width set and put the padding on that inner div, while not giving it a width.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Try your hand at the new JavaScript Challenge!

    If you don't like getting your feet stuck in a bog, avoid Twitter BootsTrap.

Bookmarks

Posting Permissions

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