Intermediate CSS Workshop

Question 4

The answer to 4.a:

First of all, I have a short mini-lecture on this topic.  There's a link to it in the classroom.  Here's another link to the file:  selector matching exercise.

One possible answer to the first question is:

a:first-child { font-weight: bold; }

This is also where knowing how to draw a document tree comes in so handy.  If you draw a document tree for the markup in this question, you'll see right away that the two links in question here are the only two links (a elements) that are first-child elements - in the entire markup.  That makes writing the answer a piece of cake.  In most cases, this sort of exercise is all about determining what makes the element or elements different from the rest of the markup.  It is an academic exercise, but it can also be very handy in the real world.