Why is it then that when I use the exact same code (that I posted earlier) it works on other pages?
Well the thing is that is not the exact same code, on that page the button is nested in a table cell which is nested in a form. It is probably setting up a whole new algorithm in IE which is effecting it somehow.
Please tell me that page is the old site and that you are rebuilding it.
The page is a mess with all the absolute positioning, non semantic html and inline css.
You are using divs for what should be list items in your main menu, not to mention that they are nested in a span.
I’ll stop there because all that is beyond the scope of your thread but as I mentioned I suspect it all has something to do with why things are rendering different in IE7 on that page.
Your code works beautifully. Why is it then that when I use the exact same code (that I posted earlier) it works on other pages? For example: http://bobbssaltandfeed.com/oosignin.php
Did I put the wrong doctype?
No, that doctype did fix IE8 but IE7 seems to have other issues. About the doctype though, always use a strict doctype when you are building a new page.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
Transitional doctypes are for old pages that are in transition, that is they are undergoing code updates.
From looking at the SitePoint Reference I see that the button element is known to be buggy in IE.
It looks like IE7 is choking on the text-indent:-9999px; It seems to be taking the entire button off screen with it.
I fixed it by wrapping the text in a span and then using margin-left:-9999px to hide the text. You should be wrapping form elements up in a block element too.
This code works in IE7/8 and FF, I didn’t test any further than that.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Button Test</title>
<style type="text/css">
.logout {
width:69px;
float:left;/*optional*/
}
#submitlogout {
width:69px;
height:26px;
/*text-indent:-9999px; chokes IE7*/
overflow:hidden;
border:0;
background:url(images/LogOutButton.png) no-repeat 0 0;
cursor:pointer;
}
#submitlogout span {
margin-left:-9999px;/*hide text off screen in a span*/
}
#submitlogout:hover {
background-position:0 -26px;
}
</style>
</head>
<body>
<div class="logout">
<button type='submit' id='submitlogout' name='LogOut'><span>Log Out</span></button>
</div>
</body>
</html>