tags:

views:

83

answers:

4

Im going mad trying to figure out why the title link (in the left) and the other links in the nav bar (right) are not the same height.

The difference is subtle in Safari, but bigger in IE6.

Im missing something in the css reset of H1?

SAFARI
alt text

IE6
alt text

The HTML

<div id="navbar">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td align="left">
            <h1><a href="http://ide.as"&gt;title&lt;/a&gt;&lt;/h1&gt;

        </td>
        <td align="right">
            <a href="about.html" class="color1">about</a>
            <a href="faq.html" class="color2">answers</a>
            <a href="contact.html" class="color3">contact</a>
            <input type="text" name="search" value="" id="searchbox">&nbsp;<a class="color4" href="sss">search</a>
        </td>
    </tr>
    </table>
    </div>

and the css

#navbar a, h1 a { padding: 3px 5px; vertical-align: middle;}

h1 has been reset

h1 {margin:0;padding:0;}
h1 {font-size:100%;font-weight:normal;}
+3  A: 
h1 a { padding: 3px 5px; vertical-align: middle;}

sets a style for a link within an h1, not the h1 itself.

h1 {margin:0;padding:0;}
h1 {font-size:100%;font-weight:normal;}

sets the style for an h1. So the styles for the link still stand, they have not been overwritten.

Tim Hoolihan
But then the parent h1 should not affect the link inside, so the `#navbar a` (ie the gray links in the right) should be the same as `h1 a` (ie the white title). Or am I missing something here?
Victor P
<a> tags do inherit font properties from h1 styles, is there anything that would set the "#navbar a" to a different font-size or font-weight? as mentioned below, i would use firebug to see what is getting inherited.
Tim Hoolihan
+1  A: 

There are some very subtle differences in the way different browsers render styling. This is just another example of it.

To see a REALLY good example of this, try looking at the Acid 2 test in each browser to see some of the differences.

md5sum
but that's why a css reset exists or not? Im concerned more why two elements with the same style are shown differently in the same page.
Victor P
A: 

First, if this happens cross-browser, use Firebug in Firefox to tell you where an element's style rules are coming from.

Second, I'd check the line height on the <a> and <h1> as well as the margins on the <a>.

Mr. Shiny and New
Thannks. Did a `h1,a{line-height: 100%;}` and a `a{margin: 0;}` without success (Safari was the same, IE6 was worse)
Victor P
+2  A: 

I think it's because the text input in the right table cell is causing that table cell to "stretch" a little taller than the left table cell (and it will be slightly different on different browsers depending how large they draw the text input box) and thus throwing off the alignment a bit. Try vertical-align:bottom; on the left table cell.

JenPinVT
That solved the problem, Thank you very much Jen!
Victor P