SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Default padding above and below text

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default padding above and below text

    There seems to be 2 or 3 pixels automatically inserted above and below all the text on my page.

    Is this something to do with the default line-height setting?

    If so, what should I set line-height to be so that there is no padding around text by default?

  2. #2
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You probably need to zero out margins and padding on the body selector, since by default, most all elements have them applied:

    Code:
    body{
    margin:0;
    padding:0;
    }
    Then apply margins/padding to specific elements in the page such as:

    Code:
    h3, h4{
      margin:10px 0;
      padding:10px;
    }
    To get the most accurate results, we would need to see a page.
    Ryan Butler

    Midwest Web Design

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the quick reply.

    I've already set margin and padding to 0 in the body tag.

    This pretty simple code demonstrates what I mean:

    Code:
    body {
    margin:0;
    padding:0;
    background-color:#ffffff;
    color:#000000;
    font-family:Verdana, Arial, Helvetica, sans-serif;
    }
    
    #guestBookHeader {
    background:url('../img/sectionHeaderTrim.gif') no-repeat top left #333333;
    margin:0;
    padding:0;
    text-align:right;
    color:#FFFFFF;
    font-weight:bold;
    }
    Code:
    <div id="guestBookHeader">
    	Guest Book
    </div>

  4. #4
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's no space above or below the text in your example, I thought that was what you wanted? If you place a paragraph tag or heading inside the guestBookHeader, then simply add another selector:

    Code:
     #guestBookHeader p{
     padding:0;
     margin:0;
     }
    If you do a heading tag, simply adjust the h2,h3,h4 for the p above. Or am I missing something?
    Ryan Butler

    Midwest Web Design

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rbutler
    There's no space above or below the text in your example, I thought that was what you wanted? If you place a paragraph tag or heading inside the guestBookHeader, then simply add another selector:

    Code:
     #guestBookHeader p{
     padding:0;
     margin:0;
     }
    If you do a heading tag, simply adjust the h2,h3,h4 for the p above. Or am I missing something?
    There is some space - if you set the font-size on the body to 80% or 90%, it's clearer. It's only a couple of pixels top and bottom but makes it very difficult to create pixel perfect pages.

  6. #6
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Trying to create pixel perfect web pages is kind of like trying to fix a car which has multiple problems with one wrench. No visitor is going to complain if you're off a hair or two pixel wise, believe me, I used to be this picky and no ever notices.

    If its something extremely crucial you'll simply have to play with settings. If not, I'd leave it be.
    Ryan Butler

    Midwest Web Design

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
  •