 <p>First of all, if I understood you, for what you want you are going to need jQuery, why? Because javascript doesn't know what CSS properties are affecting to an specific element.</p> <p>Second, the way you are using CSS is not the correct one, you are mixing desing and functionality and for the easiest task like this one you will encounter problems like this one. CSS is not intended to show or hide menus even if you can, CSS is to style things even dinamically but when the user interaction gets involved you are screwed. So be careful :P</p> <p>In jQuery should be something like this:</p> <pre><code>$(document)​.ready(function() { $('ul').on('click', 'li a', function() { $(this.parentElement.parentElement).hide(); }); });​ </code></pre> <p><a href="http://jsfiddle.net/5TBFr/25/" rel="nofollow">http://jsfiddle.net/5TBFr/25/</a></p>