This week we have possibly the toughest quiz so far of all these quizzes and once again is something that was deemed impossible to do.

Yurikolovsky has come up with a way of making a single level drop down that works in IE6 without any javascript.

Whaaat! I hear you say "that's impossible".

That's what I though until he told me he had a fully working version that uses valid html and css. As an exercise and before looking at his code I thought I'd give it a try and see if I could come up with something as I didn't want to set a quiz that nobody could do. After a few hours of fiddling around I managed to get a version working in IE6 although it is a little buggy but it did show me that it was possible to do and that there were perhaps a few other ways this could be done also.

Look at the attached screenshot and you will see Yurikolvsky's menu in its normal and expanded state (and also a screenshot of my attempt).

Your mission is therefore to create a single level drop down that will work in IE6 without javascript and also work in other browsers (though of course you can offer good browsers more advanced code etc).

The basic rules are:

valid css/htmlno tablesno javascriptNo expressions/behaviours etcno conditional comments in the body of the html (conditional comments in the head of the page are acceptable )No invalid nested anchors.

The top row of the menu should be a fluid width if possible although I will be lenient with the rules as this is a very hard task. The sub menus can be fixed width but I will be interested in any method that is working in some form or another.

You can use your own html but I will reproduce the html from my example as a starting point.

<div id="navigation">
<h1>IE6 only Demo</h1>
<ul class="nav">
<li><a class="target" href="#">Top Link1</a>
<ul class="sub">
<li><a href="http://www.google.com/">Google</a></li>
<li><a href="http://www.yahoo.com/">Yahoo</a></li>
<li><a href="http://www.pmob.co.uk/">Pmob.co.uk</a></li>
<li><a href="#http://www.sitepoint.com/">Sitepoint</a></li>
</ul>
</li>
<li><a class="target" href="#">Top Link2</a>
<ul class="sub">
<li><a href="#1">Link1</a></li>
<li><a href="#2">Link2</a></li>
<li><a href="#3">Link3</a></li>
<li><a href="#4">Link4</a></li>
</ul>
</li>
<li><a class="target" href="#">Top Link3</a>
<ul class="sub">
<li><a href="#1">Link1</a></li>
<li><a href="#2">Link2</a></li>
<li><a href="#3">Link3</a></li>
<li><a href="#4">Link4</a></li>
</ul>
</li>
<li><a class="target" href="#">Top Link4</a>
<ul class="sub">
<li><a href="#1">Link1</a></li>
<li><a href="#2">Link2</a></li>
<li><a href="#3">Link3</a></li>
<li><a href="#4">Link4</a></li>
</ul>
</li>
</ul>
</div>
<div class="content">
<p>This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : This is some following content : </p>
</div>

The above html is all that I needed for my example but as I mentioned already my example is a bit buggy and extra elements are used in Yurikolovskys example which makes it work flawlessly.

NOTE:I know there is a clever version out there by Stu Nichols that doesn't use any javascript but Stu's version relies on the fact that a table is nested inside an anchor which is invalid. To make it valid the nested code is hidden using conditional comments in the html but in essence the code is still invalid but just hidden from the validator. It also means that the html is more complicated because of all the extra table tags and conditional comments on every level.

That's the reason that I have not allowed any conditional comments in the body of the html and that the html must indeed be valid html and you can't just nest anchors.

Oh and if you want to add tab support to the menu and it's drop down then feel free

Edit:

Here are some additional comments from Yurikolovsky that may aid with your task.

[edit]

i would also give the structure of this quiz, becauseessentially its 1 big quiz consisting out of (at least) 4 little quizzes

to start: this is the dropdownMAIN LINKsublinksublinksublink

1.- getting the main link to move the sublinks2.- getting the sublinks to move the sublinks3.- hiding the dropdown links when the main link is not being hovered4.- maintaining a background on the main link when the sublinks are being hovered (initially i thought this would be impossible)

[/edit]

Any questions or if anything is unclear just ask and remember this is just for fun (although this solution will indeed be a workable solution for IE6)

Solutions to the quiz will be posted at the end of the week (or longer) depending on how it goes

in my version, there are 2 extra divs per table to make it work, and then 2 more tags per main link for background color styling and 1 extra div for extra styling.this is so the background on the main link remains lit when the sublinks are being hovered.

in my version tabbing also works very good, a little buggy when hovering and tabbing in the flexible width version but i also have a version with fixed with main-links where tabbing works flawlessly, this is a side-effect of the valid html/css used (to say, when making it, i did not intent it to support tabbing, but it does, which is nice).

also i think the html is clean enough for real life use, although this depends from person to person.

YuriKolovsky
—
2009-08-30T13:26:10Z —
#3

its not really "that" hard,so lets see who is "css" enough

ruskin012
—
2009-08-31T04:55:53Z —
#4

I think that I know CSS well but your tests realize me that I know only a little about it.

ryanhellyer
—
2009-08-31T05:55:35Z —
#5

I'm guessing this will require using an <a> tag in an odd-ball way? I can't think of any other way to trigger a hover effect in IE6. Or perhaps there are other tags which support the :hover pseudo class?

I just took at the HTML you used and it doesn't use the <a> tag in an odd-ball way.

You have me stumped! I assumed this was entirely impossible. Kudos to YuriKolovsky for figuring this out.

I'm guessing there needs to be an IE conditional comment to serve different CSS to the different browsers, but beyond that I have absolutely no idea where to even start

YuriKolovsky
—
2009-08-31T07:42:43Z —
#6

I'm guessing there needs to be an IE conditional comment to serve different CSS to the different browsers, but beyond that I have absolutely no idea where to even start

the only browser that doesn't understand this trick is surprisingly Opera, all of the other browsers work just fine with it (i was a little amazed that its so well supported, probably because its clean css mechanics and no odd ball trickery, can't say the same for paul's version, so feel free to use odd balls in your solution :)).luckily Opera supports li.link:hover .sub {maintain dropdown} which i used for opera to remove all buggy-ness it had, all the other modern browsers see this css too, and it does no harm or good (i think it slightly improves smoothness in firefox3, although its already very smooth)

the version i provided has no conditional comments at all but it does have things like #nav > .link:hover .sub {} to only serve css to modern browsers, i did this to demonstrate that it could be done without any conditional comments, but using some might make the code more tidy.

notes:my version:works identically in ie5-6 no conditional commentsslight improvements for modern browsers, but functionality is basically the same.

pauls version:slightly buggy in IE6, but potentially can be fixed.modern browsers use modern techniques.

to start, what CAN you hover in all browsers? now use that to the fullest.

ryanhellyer
—
2009-08-31T08:30:19Z —
#7

The big question is ... how come no one has discovered this before?

People have been trying to come up with a cross-browser way to do this for years and the best route that I've seen is to use IE conditional comments around table tags which produces some horrid looking HTML.

YuriKolovsky
—
2009-08-31T08:51:48Z —
#8

ryanhellyer said:

The big question is ... how come no one has discovered this before?

People have been trying to come up with a cross-browser way to do this for years and the best route that I've seen is to use IE conditional comments around table tags which produces some horrid looking HTML.

hahaha that is a excellent question, and i have no idea why! maybe lack of lateral thinking? or maybe css has not yet been explored enough? or maybe everyone said it was impossible and people simply never tried to make it work.

i mean, it is perfectly possible, else paul would not be hosting this quiz.

edit:a little story: about a couple years ago some sailors discovered a huge sunken (several hundred year old) treasure near gibraltar, governments of spain and gb were fighting over who it belongs to, but why did none of the millions of ships passing by discover it before? just proves that there are things that have not been discovered lurking behind every corner.

edit:what makes this quiz hard is the lack of Internet aid you will be getting, i could not find any tutorials or dropdowns like this.

PaulOB
—
2009-08-31T09:09:58Z —
#9

or maybe everyone said it was impossible and people simply never tried to make it work.

I must admit I never bothered to even try previously as I assumed it wasn't possible but after a few hours of playing around I could see ways that this could be done in a few ways although some are a bit buggy.

ryanhellyer
—
2009-08-31T09:58:09Z —
#10

I've pounding away at this for over an hour and am getting no where What on earth apart from an <a> tag can handle :hover?

YuriKolovsky
—
2009-08-31T10:14:27Z —
#11

What on earth apart from an <a> tag can handle :hover?

to the best of my knowledge not even <a> supports :hover across all browsers, i think only <a href=""> (href="" is very important) supports hover cross all browsers, not sure, i may be wrong here.

Stomme_poes
—
2009-08-31T13:48:06Z —
#12

What on earth apart from an <a> tag can handle :hover?

asked that way, I thought <area>s did as well (dunno, never used them).

Interesting. As usual I will be my lazy self and reap the rewards after other people lose their hair figuring it out : ) Hm wait, I had an idea...

system
—
2009-08-31T19:51:06Z —
#13

I don't have time to work out the exact code, but I know how it could be done.

Today, I started redesigning a site I made for a client a couple of years back. The menu is pure CSS. Though it is vertical rather than horizontal (and features graphics rather than dropdowns), it could very easily be adapted to achieve the result you are looking for.

My example uses dual classes (ie; class="site point"), and this would probably be one of the keys to a fully functional dropdown menu. My code also uses an MS conditional statement to access a dedicated IE6 stylesheet, but with further tweaking it may be possible to do away with this.

PaulOB
—
2009-08-31T20:28:07Z —
#14

andrew-bkk said:

I don't have time to work out the exact code, but I know how it could be done.

No that won't work I'm afraid

With that method you can only have one link destination. The drop down requires multiple link destinations.

Think again

PaulOB
—
2009-08-31T20:32:13Z —
#15

Ryan said:

What on earth apart from an <a> tag can handle :hover?

You don't need to look for anything else as the hover on the anchor is all you need.

Think of ways that hovering on an anchor can push something else into view. Remember to test with IE6 as other browsers may not exhibit the same behaviour and they can be fixed in the normal way anyway.

If we don't get any takers for this we will give out more hints and tips along the way to point you in the right direction.:)

rochow
—
2009-08-31T23:28:54Z —
#16

Without putting much thought into it, using negative margin to pull the <ul> up on hover.

The big question is ... how come no one has discovered this before?

1) Too busy doing paid projects, gotta pay the bills!2) Have you tried finding out new ways of doing things? Lots of time + stress when its working, only to find its broken in X browser. Fix X browser and it's broken in Y browser. And round and round she goes.3) Someone else can do the hard and stressful work, then you can implement it I figured out a way of not needing <li class="first"> or <li class="last"> to negate certain effects, say a border separating all menu items except its not needing on either the first or last item (in certain situations at least). However, I later found out someone else had already figured it out... so I basically wasted half a day

ryanhellyer
—
2009-09-01T01:04:12Z —
#17

rochow said:

Without putting much thought into it, using negative margin to pull the <ul> up on hover.

But how are you going to target the <ul> tag on hover? You need an <a> tag for that, but the one you would typically be targetting does not have the UL tag nested inside it which makes it impossible to make it work with IE6 ... or so I thought until seeing this forum topic.

Rayzur
—
2009-09-01T01:09:36Z —
#18

I have a dropdown on hover in IE6

Now I got to figure out how to hold it open when I go to the first link in the sublist. I don't know if I am on the right trial or not though.

rochow
—
2009-09-01T01:12:28Z —
#19

Which <ul>, the one with the sub items? You don't need too. Say you have 20000px bottom margin on <a class="target"> or whatever it is. This pushes the menu out of site (until you scroll that is ). Then, on hover, you make the margin 0. Pow, it's now visible as it's brought back up beneath the <a>. Though I haven't figured out how you'd hide it... like I said, quick theory

ryanhellyer
—
2009-09-01T03:43:43Z —
#20

rochow said:

Which <ul>, the one with the sub items? You don't need too. Say you have 20000px bottom margin on <a class="target"> or whatever it is. This pushes the menu out of site (until you scroll that is ). Then, on hover, you make the margin 0. Pow, it's now visible as it's brought back up beneath the <a>. Though I haven't figured out how you'd hide it... like I said, quick theory

Hmmm, interesting theory.

I guess I've always ruled out stuff like that since it's likely to mess up other code on the page.