In the following markup without changing it or using JS, implement the behavior to show only the ul element of div which name is clicked in the first ul (before div). Name is content of li in top ul and it matches the content of the first li in ul you want to show. Elements that have {content} are just fillers and have no meaning for problem.

  <li class="head"><a href="#favorites">Favourite dishes</a></li>
  <li><a href="#breakfasts"><i>Breakfasts</i></a></li>
  <li><a href="#dinners"><i>Dinners</i></a></li>
  <li><a href="#suppers"><i>Suppers</i></a></li>
    <ul id="breakfasts">
       <li class="head">Breakfasts</li>
       <li>{Breakfast 1}</li>
       <li>{Breakfast 2}</li>
       <li>{Breakfast 3}</li>
    <ul id="dinners">
       <li class="head">Dinners</li>
       <li>{Dinner 1}</li>
       <li>{Dinner 2}</li>
       <li>{Dinner 3}</li>
    <ul id="suppers">
       <li class="head">Dinners</li>
       <li>{Supper 1}</li>
       <li>{Supper 2}</li>
       <li>{Supper 3}</li>
    <ul class="favorites">
       <li class="head">Favourites</li>
       <li>{Favourite 1}</li>
       <li>{Favourite 2}</li>
       <li>{Favourite 3}</li>

This problem really has the solution and was very interesting for me, so I decided to post it here even if it's not very practical. Hint: you have to use :target pseudo-class.

  • 4
    \$\begingroup\$ Note, I don't believe this is off-topic, as it looks like a programming-puzzle to me \$\endgroup\$ – Nathan Merrill Aug 19 '16 at 18:11
  • 2
    \$\begingroup\$ @NathanMerill Programming puzzle or not, it still needs an objective winning criterion. \$\endgroup\$ – Dennis Aug 19 '16 at 18:20
  • \$\begingroup\$ @Dennis isn't it first posted by default? \$\endgroup\$ – Nathan Merrill Aug 19 '16 at 18:26
  • \$\begingroup\$ @NathanMerrill Amended: first corrected posted \$\endgroup\$ – Conor O'Brien Aug 19 '16 at 18:26
  • 2
    \$\begingroup\$ @NathanMerrill As far as I know, no. The tag doesn't even have a wiki. \$\endgroup\$ – Dennis Aug 19 '16 at 18:31

I think your hint gave too much away:

   display: block;
   display: none;
  • \$\begingroup\$ thanks for proposing a solution, it's almost it, but if I click the "Favourite dishes", nothing is shown \$\endgroup\$ – snowfinch27 Aug 19 '16 at 18:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.