Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Accordion not working

This question is in regard to these:

https://teamtreehouse.com/library/create-an-accordion-menu-with-css

http://teamtreehouse.com/library/create-an-accordion-menu-with-css-2

Unfortunately both of these have issues in older desktop browsers (like IE6), old Android browsers, and using them in Joomla, which doesn't have a convenient way to insert CSS on a per-article-basis without messing with the associated template's CSS.

Fortunately I'm working on migrating the site from Joomla to Wordpress and under WordPress there is a old CSS Manager plugin:

http://mywebsiteadvisor.com/tools/wordpress-plugins/custom-css-manager-plugin/

--that adds a custom css injection section to each WP Page edit screen.

Here's the simple HTML I used for testing:

</ul>
</li>
<li><a href="#">Header 3</a>
<ul>
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
<li><a href="#">Item 3</a></li>
<li><a href="#">Item 4</a></li>
</ul>
</li>
<li><a href="#">Header 4</a>
<ul>
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
<li><a href="#">Item 3</a></li>
<li><a href="#">Item 4</a></li>
</ul>
</li>
</ul>

Here's the accordion CSS that worked (except IE6 which will

probably needs a javascript polyfill):

.accordion-menu li { width:150px; }
.accordion-menu a {
    display:block;
    width:148px;
    padding:2px;
    background:#aaddaa;
    border:1px solid #99aa99;
    border-radius:3px;
    margin:1px;
    text-decoration:none;
    color:#337733;
    font-weight:bold;
}
.accordion-menu ul a {
    text-indent:10px;
    background:#ddffdd;
    color:#77aa77;
}
.accordion-menu ul a:hover {
    color:#fff;
    background:#339933;
}
.accordion-menu, .accordion-menu ul { padding:0; margin:0; }
.accordion-menu li { list-style:none; }
.accordion-menu li ul { display:none; }
.accordion-menu li:hover ul { display:block; }

There are several javascript based pseudo class fix/hacks out there for IE6.

I've used this one more than once:

http://robspangler.com/blog/hover-pseudo-class-bug-fix-for-ie6/

I wish the course above had at least mentioned a links to a few such IE6 hacks to try and extend the backward compatibility for accordions.

I also wish more of the Treehouse site used accordions.

1 Answer

Bram Dijkhuis
Bram Dijkhuis
5,746 Points

I think in most cases developing for IE6 is a waste of time and resources. I do believe in backwards compatibility, but I also strongly believe that there is a limit to the extent in which you should support it. Right now IE6 is a 14 year old browser which has seen it's last stable release in 2008. Even Microsoft started to urge users to upgrade to newer versions of IE over 5 years ago. Latest usage statistics show that the market share of IE6 is below 1% as of may 2015 with the only exception of China where the market share is at 3%. So unless you're targeting that specific 3% audience in China there's no valid argument for still supporting IE6.

A lot of web application development companies have already dropped support for IE8 and older and some are even dropping IE9 support.