Welcome our webmaster and SEO forum
Please enjoy the forum, contribute what you can, and wind up the Moderators!
Results 1 to 8 of 8

Thread: space above H2 in ie

  1. #1
    unclecurio is offline Junior Member
    Join Date
    Feb 2009
    Posts
    3

    Post space above H2 in ie

    Okay, I'm sure this is rookie cross-browser stuff but I can't seem to turn up an answer to the problem so I'm hoping someone here can help!

    HTML Code:
    <div id="sidebar">
    <h2>Navigation</h2>
    Some links go here
    </div>
    Now, I've styled the h2s thus...

    HTML Code:
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 1.2em;
        font-weight: normal;
        padding-top: 4px;
        padding-right: 0px;
        padding-bottom: 5px;
        padding-left: 5px;
        width: 215px;
        float: left;
        display: block;
        height: 25px;
        background-image: url(siteimages/backdrop-side-h2.gif);
        background-repeat: repeat-x;
        background-position: left bottom;
        margin: 0px;
    And the containing sidebar div thus...

    HTML Code:
    sidebar1 {
        float: left; 
        width: 220px;
        padding: 0px;
        margin: 0px;
    }
    All is well in pretty much every browser - the H2 with it's backdrop sits snugly at the top on the sidebar DIV. However, in IE, there is a large gap above it which I can't work out how to resolve.

    This is driving me slightly nuts - can anyone suggest a reason for this?

  2. #2
    surreypcsupport's Avatar
    surreypcsupport is offline Senior Member
    Join Date
    Nov 2008
    Location
    surrey
    Posts
    565

    Default

    Quote Originally Posted by unclecurio View Post
    Okay, I'm sure this is rookie cross-browser stuff but I can't seem to turn up an answer to the problem so I'm hoping someone here can help!

    HTML Code:
    <div id="sidebar">
    <h2>Navigation</h2>
    Some links go here
    </div>
    Now, I've styled the h2s thus...

    HTML Code:
        font-family: Verdana, Arial, Helvetica, sans-serif;
        font-size: 1.2em;
        font-weight: normal;
        padding-top: 4px;
        padding-right: 0px;
        padding-bottom: 5px;
        padding-left: 5px;
        width: 215px;
        float: left;
        display: block;
        height: 25px;
        background-image: url(siteimages/backdrop-side-h2.gif);
        background-repeat: repeat-x;
        background-position: left bottom;
        margin: 0px;
    And the containing sidebar div thus...

    HTML Code:
    sidebar1 {
        float: left; 
        width: 220px;
        padding: 0px;
        margin: 0px;
    }
    All is well in pretty much every browser - the H2 with it's backdrop sits snugly at the top on the sidebar DIV. However, in IE, there is a large gap above it which I can't work out how to resolve.

    This is driving me slightly nuts - can anyone suggest a reason for this?

    Is the page content contained within a table? If you add the attribute topmargin=0 to the top level table it may well solve the problem although topmargin is unsupported in xhtml 1.0.

  3. #3
    unclecurio is offline Junior Member
    Join Date
    Feb 2009
    Posts
    3

    Default

    Thanks for the reply but no, the whole thing is done in DIVs. This is really driving me nuts!

  4. #4
    BlueBoden's Avatar
    BlueBoden is offline Member
    Join Date
    Nov 2008
    Posts
    72

    Default

    There are some basic more or less undefined rules you must follow, or keep in mind with cross-platform/browser compatibility.

    The space above your heading, is likely removed by removing the margin on the tag, if that doesn't work directly, try something like margin-top: 0 !important; The !important rule will overwrite other declarations, but try not to rely to much on it, as it doesn't seem to overwrite other properties declared with !important.


    I usually reset the margin/paddings for everything with below, and then declare them later. Because i likely need to change them anyway.
    Code:
     
    * {
    margin: 0;
    padding: 0;
    }
    Also be sure to include a valid doctype, some margin/padding issues can occur when browsers are switched into backwards compatibility mode, the doctype should be placed on the first line in the site/document.

    The topmargin attribute is non-standard, and should not be used. Even if it where standard, it would have been replaced by better alternatives by now, such as CSS Properties.

    You do not need to apply display: block; on h2 elements, as the h1-h6 elements are block-level elements by default. Also note that any floated elements automatically becomes block-level elements, so you do not need to set inline elements to block when floating them.
    Last edited by BlueBoden; 02-22-2009 at 10:48 AM.

  5. #5
    unclecurio is offline Junior Member
    Join Date
    Feb 2009
    Posts
    3

    Default

    Thanks for the reply - that's a feature I wasn't aware of before.

    I finally discovered the problem stemmed from the fact that the file I was editing had been created in Dreamweaver originally and had an 'if IE' conditional attribute that whacked on an extra 30 pixels of padding!

    The moral is always beware of other people's code!

  6. #6
    Scorpyan is offline Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default

    And avoid dreamweaver graphical editing!

  7. #7
    anurdh65 is offline Junior Member
    Join Date
    May 2009
    Posts
    9

    Default

    #menu {
    width: 12em; /* set width of menu */
    background: #eee;
    }

    #menu ul { /* remove bullets and list indents */
    list-style: none;
    margin: 0;
    padding: 0;
    }

    /* style, color and size links and headings to suit */
    #menu a, #menu h2 {
    font: bold 11px/16px arial, helvetica, sans-serif;
    display: block;
    border-width: 1px;
    border-style: solid;
    border-color: #ccc #888 #555 #bbb;
    margin: 0;
    padding: 2px 3px;
    }

    #menu h2 {
    color: #fff;
    background: #000;
    text-transform: uppercase;
    }

    #menu a {
    color: #000;
    background: #efefef;
    text-decoration: none;
    }

    #menu a:hover {
    color: #a00;
    background: #fff;
    }

  8. #8
    hannah123 is offline Junior Member
    Join Date
    Dec 2009
    Posts
    7

    Default Reply

    Use padding=0 there

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124