Your selector is perfectly fine, what is wrong is the lack of 'style' for the border.
Something like border: 2px solid;
would work just fine. This will set all four sides to be 'solid' at 2px thick; opposed to the default 'none' at 'medium', what ever 'medium' is.
Just as a side note or point of reference, your current selector is 'any img tag that is a descendent of a #gallerywrapper', if you swap to #gallerywrapper > img
you will get only the direct children. In other words, buy adding the >
you could have say a <p>
with an image in it would not get a border, and as it is not a direct child. Either way works given the HTML the OP posted, and neither is 'bad'.