Tabs aren't cross browser?

When I tested my tabs, I found out that they aren’t cross browser. They don’t display the rounded corners in every browser, except in the latest Firefox and Internet Explorer version. I have been trying to find out why this is happening, but haven’t been able to work it out, so can someone please tell me why this is happening? Thanks in advance.


#mainMenu {
    float:left;
    width:100%;
    font-size: 14px;
   list-style:none;
}

#mainMenu li {
	display: inline;   
}

#mainMenu a:link, #mainMenu a:visited {
    background: url('images/tab-left.gif') no-repeat left top;
    margin-right: 1px;
	padding: 4px 7px 5px 5px;
    text-decoration:none;
    color: #000;
    text-align: center;
}

#mainMenu a:link span, #mainMenu a:visited span {
    background: #DADADA url('images/tab-right.gif') no-repeat right top;
    color:#000;
    margin-right: 1px;
    text-decoration:none;
    padding: 4px 7px 5px 5px;
    text-align: center;
}

#mainMenu a:hover {
    margin-right: 1px;
	color: #000;
	text-decoration: none;
    background: url('images/tab-left.gif') no-repeat bottom left;
	padding: 4px 7px 5px 5px;
    text-align: center;
}

#mainMenu a:hover span {
    margin-right: 1px;
	color: #000;
	text-decoration: none;
    background: #C2C1C1 url('images/tab-right.gif') no-repeat bottom right;
	padding: 4px 7px 5px 5px;
    text-align: center;
}


<ul id="mainMenu">
	<li><a href="#"><span>Home</span></a></li>
	<li><a href="#"><span>Partner Profiles</span></a></li>
	<li><a href="#"><span>Photos</span></a></li>
	<li><a href="#"><span>Careers</span></a></li>
	<li><a href="#"><span>Client Base</span></a></li>
	<li><a href="#"><span>News</span></a></li>
	<li><a href="#"><span>Contact</span></a></li>
	<li><a href="#"><span>Sitemap</span></a></li>
</ul>

Hi,
Without your images I will have to just work with BG colors but I am seeing some things in your code that are not needed.

You should be able to just set your tab-left.gif on #mainMenu a and be done with it. There is no need to define it again on the pseudo states. Same goes with the tab-right.gif on the span, it should just be set on #mainMenu a span

It looks like you set the same padding on your anchor and span. I would think they should be opposite of one another with vertical padding on the span only if that is how you were setting your height. There again hard to tell without your images.

I would be floating my anchors and spans to generate block boxes around them. That will get rid of whitespace nodes and keep your margins consistent with what you are setting them at. At the same time you will also be able to set heights if that is needed for your images.

See if this works better for you, pay no attention to the BG colors or just remove them.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Tabs Test</title>

<style type="text/css">
body {
    margin: 0;
    padding: 5px;
    font:100%/1.4 arial, helvetica, sans-serif;
}
#mainMenu {
    float:left;
    width:100%;
    margin:0;
    padding:0;
    font-size:14px;
    list-style:none;
    background:#BBB;
}
#mainMenu li {
    float: left;
}
#mainMenu a {
    float: left;
    margin-right: 4px;
    padding: 0 0 0 8px;
    background:orange url('images/tab-left.gif') no-repeat left top;
    color: #000;
    text-decoration: none;
}
#mainMenu a span {
    float: left;
    padding: 4px 8px 4px 0;
    background: #CDF url('images/tab-right.gif') no-repeat right top;
}
#mainMenu a:active,
#mainMenu a:focus,
#mainMenu a:hover {
    color: #00F;
}
</style>

</head>
<body>

<ul id="mainMenu">
    <li><a href="#"><span>Home</span></a></li>
    <li><a href="#"><span>Partner Profiles</span></a></li>
    <li><a href="#"><span>Photos</span></a></li>
    <li><a href="#"><span>Careers</span></a></li>
    <li><a href="#"><span>Client Base</span></a></li>
    <li><a href="#"><span>News</span></a></li>
    <li><a href="#"><span>Contact</span></a></li>
    <li><a href="#"><span>Sitemap</span></a></li>
</ul>

</body>
</html>


Thanks for your help, Rayzur.

I have decided to keep the hover state to a text color change, as I don’t have the time to go further with this. I will have to test your code in other browsers, and then I will get back to with the result.

@Rayzur

Is the float:left; really necessary on <li>s? I would use display:inline;.

@!designer!

That tab-left|tab-right thing is about the sliding doors technique? 'Cos it’s not working if so.

Much less that without a height trigger that dual float will staircase in IE7 :stuck_out_tongue:

As others said we’d have to see the images, though I suspect you are using multiple images to do the job of one, Rayzur was quite correct in pointing out you are restating values on the various psuedostates for no good reason, the double-nested padding seems to be overcomplicating something simple, and by not stating a line-height you cannot predict the actual height of those elements consistently cross-browser since you can NEVER trust a default or inherited line-height.

I always prefer to be in block mode with all my nav/menus. With the code I posted above display:inline would have worked while using anchor and span as hooks for the BG images. To be honest that span is not really even needed, the left image could have been hooked to the LI and in that case we would need it to be floated. As shown in the code below, if you try to change it to display:inline it just won’t work.

I am not seeing the staircase bug with the code I posted above. It works fine with or without a height. We’ve been through this before, and I give the same reply every time, “The staircase can be fixed by EITHER floating the LI or setting it as display:inline”. They both fix the bug. I know you always say: “Forget about the LI and don’t even try to style it”. That also contradicts other statements you have made in the past: “Why waste an element that is capable of being a hook for styles”. I completely agree with that last statement.

About the inherited line-height issue, yes I see that it can be problematic x-browser.

Here is that code without the nested spans (which are not needed) and in order to hook the left BG image to the LI it must be floated which is how I would do it.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Tabs Test</title>

<style type="text/css">
body {
    margin: 0;
    padding: 5px;
    font: 100%/1.3 arial, helvetica, sans-serif;
}
#mainMenu {
    float:left;
    width:100%;
    margin:0;
    padding:0;
    list-style:none;
    background:#BBB;
}
#mainMenu li {
    float:left; /*display:inline; will not work with images hooked here*/
    margin-right: 4px;
    padding: 0 0 0 8px;
    background: #FFA500 url(images/tab-left.gif) no-repeat 0 0;
}
#mainMenu a {
    float: left;
    padding: 4px 8px 4px 0;
    background: #CDF url(images/tab-right.gif) no-repeat 100% 0;
    text-decoration: none;
    font: 14px/1.3 arial, helvetica, sans-serif;
    color: #000;
}
#mainMenu a:active,
#mainMenu a:focus,
#mainMenu a:hover {
    color: #00F;
}
</style>

</head>
<body>

<ul id="mainMenu">
    <li><a href="#">Home</a></li>
    <li><a href="#">Partner Profiles</a></li>
    <li><a href="#">Photos</a></li>
    <li><a href="#">Careers</a></li>
    <li><a href="#">Client Base</a></li>
    <li><a href="#">News</a></li>
    <li><a href="#">Contact</a></li>
    <li><a href="#">Sitemap</a></li>
</ul>

</body>
</html>

Yes, I appreciate that for the staircase bug you can choose. But my point was that the example provided needs spans for the sliding doors, and so the float left was not really need it.

Using just li and a it’s not a good solution for sliding doors. Think of different background colour for the parent showing a different opaque upper corners colour. And if you use transparency for the upper corners, well then, instead of a clean rounded corner it will show a mix in one of the upper corners of the backgrounds for the two elements .

Well I’m not sure which “Sliding Doors” method you are referring to but I assumed you were talking about the article from A List Apart. They are not using spans and they are floating the LI in both articles.

Sliding Doors of CSS
Sliding Doors of CSS, Part II

In the first article they mention how display:inline can be troublesome:

The First Method — and possibly the more common — is to change the display of each list item to “inline”. The inline method is attractive for its simplicity. However, the inline method causes a few rendering problems in certain browsers for the Sliding Doors technique we’re going to discuss. The [B]

Second Method[/B], which is the one we’ll focus on, uses floats to place each list item in a horizontal row. Floats can be equally frustrating. Their seemingly inconsistent behavior circumvents all natural logic. Still, a basic understanding of how to deal with multiple floated elements, and the means to reliably “break out” of floats (or contain them) can achieve wonders.

And if you use transparency for the upper corners, well then, instead of a clean rounded corner it will show a mix in one of the upper corners of the backgrounds for the two elements.
Which is a whole different scenario, The OP never even said anything about sliding doors anyway. From what I understood they were just talking about “tabs with round corners”. We will need to hear back from them in order to confirm their needs.

There are many references on the web regarding CSS tabs. One i used is http://htmldog.com/articles/tabs/.

The ALA example falls short. The tabs have an unusable graphic part which is misleading.

We’ll probably need to see what the OP says. But so far, I can’t imagine how he can manage to achieve rounded corners w/o sliding doors, given his code, and not falling short of the above.

To me is pretty clear: he uses a sliding door technique, where the tab-left picture meets up with the tab-right picture. And since using rounded corners usually means transparent upper corners, I don’t think the solution you gave is viable, again, not falling short on the misleading unusable graphical part of the tab. Strictly from the rounded corners point of view. Your code is top notch, as always :slight_smile:

And, like ds60, I believe one image or sprites at the very least would be better.

While I do, win7 XP under VirtualBox. It does NOT appear in “MultipleIE” or IE8’s compat mode – just part of why I trust neither. Fixed height trigger fixes it.


That’s the code from your most recent post… IE7, WinXP. STAIRCASE, caused BY the float!

Yes we have, and, well…

FLOATING the LI is what CAUSES it, height being the FIX for the staircase effect on floated LI.

Simple, when the element cannot be trusted to behave properly, particularly cross browser – hence the need for SPAN inside LEGEND and the occasional DIV around fieldsets when you have more than one fieldset… In the same way I’d be using extra spans inside the anchors.

Your latest code there being a perfect example of something I likely would never deploy… Why? Hover states.

  1. Your version you’d have to hover on the LI if you want both images to shift.

  2. You then could not trap :active or :focus for keyboard nav.

  3. that code DOES staircase in IE7 here.

  4. if trying to use overlapping sliding-doors on both sides, you couldn’t do transparency properly.

  5. need for something like csshover3.htc for legacy IE when you shouldn’t need to.

There’s a reason I’d use a sandbag span instead of using nested elements. You missed the finer point of my statements – I object to extra elements that serve NO purpose… like 99% of the DIV people wrap UL’s in; sandbag elements are much more predictable and problem free so sometimes you do end up resorting to them… at least until border-image becomes real world deployable some decade or so from now.

It’s like that omitting the line-height metric and style/weight that we’ve gone around and around on in the past too, which ends up with the whole property ignored in 5.5, gives 20px in IE6 for christmas only knows what reason, and of course since it’s px metric fonts thanks to FF being a retard it ends up 1px taller than it does in the rest of the browsers, which is why if you’re going to use px fonts, use px line-height! (Gotta love how FF treats 18.2 as 19 or 18 randomly depending on how far from the top of the window it’s rendered!)

We keep going around on it because what you are saying is NOT even close to what it does here…

Oh, and you’re waiting to declare the font-size and line-height causes Opera on large fonts/120dpi to make the LI taller than the anchors.

It’s why for markup I’d be using the sandbag spans:


<ul id="mainMenu">
  <li class="current"><a href="#">Home<span></span></a></li>
  <li><a href="#">Partner Profiles<span></span></a></li>
  <li><a href="#">Photos<span></span></a></li>
  <li><a href="#">Careers<span></span></a></li>
  <li><a href="#">Client Base<span></span></a></li>
  <li><a href="#">News<span></span></a></li>
  <li><a href="#">Contact<span></span></a></li>
  <li><a href="#">Sitemap<span></span></a></li>
</ul>

Oh noes, not twelve extra bytes per line!?! (file that alongside the white-space stripping nonsense)

Since then you could do your hover states in all browsers without scripting assistance, can do transparency without whatever you put on the LI showing through, set the LI to inline so you don’t have to worry about the IE7 staircase CAUSED by float on LI, (Float is not the fix, it’s the CAUSE), and trap for keyboard navigators thanks to the :active and :focus states of the anchor.

It’s also nice because you can use the exact same markup to switch to gilder-levin if a re-theme requires full images instead of images as a background.

Which ends up something like this:

http://www.cutcodedown.com/for_others/designer/template.html

using a single image for both sides and all three states:

http://www.cutcodedown.com/for_others/designer/images/mainMenu.png

While keeping the CSS

http://www.cutcodedown.com/for_others/designer/screen.css

Reasonably simple despite the addition of state handler code.

… and working IE 5.0 through 9 Beta, FF 2 and 3, Opera 9.6 or newer, and the latest flavors each of Safari and Chrome.

Which your example code does not do here, giving me about six different appearances across that slate of browsers.

Well, Im trying, but I can’t find anything wrong with ds60’s code :lol:

Once again, nice job! Text book example! It’s all about the <a>. As it should be.

I suspect that VirtualBox is causing problems for you once again, just like it did in the recent quiz. It looks like it may be time for you to stop trusting it too.

Running this code (which is the same as my last post) through a native copy of [URL=“http://api.browsershots.org/png/original/e6/e6293233099da87d545a9da545babb09.png”]IE7 at browsershots it does not show the bug.

Simple, when the element cannot be trusted to behave properly, particularly cross browser – hence the need for SPAN inside LEGEND and the occasional DIV around fieldsets when you have more than one fieldset… In the same way I’d be using extra spans inside the anchors.
Yes, I do understand why spans are needed for the hover states in functional sliding doors technique, it makes perfect sense.

You missed the finer point of my statements – I object to extra elements that serve NO purpose…
I agree, and just like you mentioned about the span inside a legend I have been in situations when an extra div was needed to make IE6/7 comply.

I just don’t see the LI as being an unpredictable element that can’t be styled.

@Rayzur

One thing I don’t like about your floating example and why I prefer ds60’s:

An <ul> having all it’s elements (and sub-elements) floated has become a useless container, a <div>, a hook for style.

You can argue it’s a strange point. I’m the first to admit. But CSS has to make sense to me too, like html has to be semantic. And ds60’s makes more sense to me. I’m 100% sold at this moment. Usability, accessibility, visual capabilities.

Like:
<li> inline seems a natural step to change the orientation. <li> floated seems an overkill. I like to think of floats as the last resort. In a perfect world, I would love to keep the <a>s from floating too.

You do have a point though: your example doesn’t staircase in IE7. And moving the float to <li>s is a solution as well for the staircase bug, not just the inline display.

But it does not provide a solution for the sliding doors with transparency on the upper corners.

[Completion of the above post. Reason: past edit time.]

I like to give the elements only a minimum CSS change. What they need, nothing more. <a> from inline to inline block is not that much of a change. <a> from inline to float seems to me a pretty big change. So it’s for <span>.

The reason why <li> from block to float seems a pretty big change to me is explained above.

In your case, floating is for making <a>s behave like an xUAs inline block. So, an inline block is what you need.

But, since inline block is buggy, you give <a>s inline capabilities by floating them. As it happens, float also qualifies for the block part in the inline block equation. Double luck for floats users :slight_smile: But still, a questionable use in my book.

Not everything goes when it comes to styling. There are some concessions to be made, but still, reasonable boundaries in changing the presentation for elements is required.

In the recent quiz it wasn’t working in all browsers on the HOST OS either, so, uhm… no… hence why I posted the FIX in that thread which is the only way to make that work here in Opera native and IE under the VM.

I just went down to my garage and tried your most recent link on the single XP box I have left, which is still on 7 for the last line of resort testing… guess what? STAIRCASE.

Besides, there is NO difference between a VM and a native install on a machine. It’s 100% the same as running on a real machine since you are running a real copy of the OS.

Though it’s funny you mention browsershots which for me has always been next to useless for testing – mind you the inability to test scrolling, resizing, and dynamic elements much less the painfully slow delay for testing are the lions share of my dislike for it – it also never seems to line up with actual testing in the real browser; Quite often I suspect the IE7 is actually 8 compat now, and I don’t know what the devil is wrong with it’s IE6 implementation but that’s NOT how IE6 renders pages for me.

NO! Floating them is to stack them, that’s what float is for. It’s NOT to make it behave like inline-block, since we don’t have white-space preservation which inline elements do. Floats are just stackable block elements; in fact it sets them to the block box model and nothing you set for display can change that (which can be an advantage in dealing with fixing IE bugs)

Maybe it’s because it’s newer in terms of widespread implementation, but to me inline-block would be the hack for things like that… using inline-block for centered menus for example IS sloppy in my mind…

But then you seem to have the default appearance tied to your ‘meaning’ of the tags when I do not. Just because anchor defaults to inline doesn’t mean you can’t set it to anything you want or should even think of restricting yourself to that.

Generally though I too avoid floats unless it’s float behavior I want; hence why quite often with things like header areas instead of floating the h1 left and a search bar or avert right, I’ll declare the h1 full width, margin:-64px 0 0 auto; the second element. (64px being the height of the h1). Removes the headaches of using floats in the top area. It’s also why I rarely ‘need’ a #header div and why I think the HEADER and NAV HTML5 elements are just wasted code undoing the past decade worth of progress in coding… The people who made endless nested tables that went to making endless nested div now will just use endless nested allegedly ‘semantic’ HTML5 elements NONE of which are needed if you just bother learning the existing HTML4 elements… More things change, the more they stay the same – see why I say that 99% of the code out there is just HTML 3.2 with a HTML4 tranny doctype slapped on it… Welcome to the bleeding edge of 1998 techniques.

In case you missed it (in post#13) I did acknowledge that the spans were needed for sliding doors, and that Jason’s example made perfect sense. :wink:

Your right, the only thing browsershots is good for is a screenshot. In this case that is enough.

That’s not IE8 chrome on that screenshot, there are no round corners on the IE tabs or gradient background behind the IE tabs. You would be seeing those if it were IE8 in compat or dev tools. It is the very same chrome that is shown in your screenshot. How do you explain that?

I haven’t noticed the IE6 chrome yet, I’ve got a test of it in the Queue right now.

EDIT:
And now we have IE6 from browsershots, I don’t see anything misleading about the chrome there either. :slight_smile:

I tried this on IE7: http://www.css-lab.com/test/ie7-test.html several times. No staircase. It seems you have another setting, common to all your computers, making the staircase appear on Rayzur code.

To stack them… inline :slight_smile:

Yes and No.
No, you cannot talk about text and about block and inline and say: “Hey, block is just what I want to think it is.” Text is text and block is block. Html didn’t invented but built upon a system. Html alone DOES convey a presentation: minimalistic and general, not precisely specific.

Which is the starting point for the specifics. Otherwise, where are the default presentational features for each element appear from? Based on what rules? Since CSS has not entered the scene yet!

Yes, I was saying in previous threads that the specs convey a default presentation. Which is not to be mistaken with the default style specifics: 16px, blue font colour for links etc.

Didn’t say that. Said: give the element the CSS change it needs and nothing more. Yes, you can make any adjustment YOU WANT. But, is the adjustment what IT NEEDS, or it is what IT NEEDS AND MORE.

Just summarizing for my self. Sorry :slight_smile:

I know I missed it, though you do NOT need it for sliding doors; just for sliding doors with transparency and the ability to have proper pseudo-states.

… and that’s not

Don’t know - but quite often when people hold up browsershots of IE7 it seems to show the behavior of IE8 in compat mode and NOT what IE7 does here – even though it’s the correct chrome around it. Makes me wonder if they are using the Tredosoft MultipleIE versions or something which are known to exhibit the same behavior on some elements… That’s the reason I have VM’s of native OS installs without trying to have multiple versions side-by-side on the same install; IE is just too tied to the host OS for that.

See how IE6 renders pages differently across 9x, NT4, NT2K and XP. USUALLY it’s things like whether you get disappearing content or double render on comments that ends up different… Though I’ve seen everything from the same core font in the same size ending up different widths to randomly deciding it’s going to screw up “APo Right” like Firefox does. (which is why my nested span uses left:100% instead of right:-8px; – the right positioning can’t be trusted!)

But I’m the guy who’s seen two identical computers with fresh just installed off the same disk versions of Vista render pages differently in IE7.

Could be worse though, could be back on IE5 where just changing video card drivers could change how the browser renders a page.

Goes back to the core problem of IE – it’s STILL too tied to the host OS; see how IE9 won’t be available for anything less than Vista for NO GOOD REASON. Even minor variations in the version or release date of the host OS can change IE’s behavior… XP VLE not being the same as XP Home or Pro… Vanilla XP upgraded to SP2 not behaving the same as the versions that came with SP2 built in, etc, etc…