Replacing Dimmer Switch
Yes, but if there is a ground wire in the box, you should attach it to the ground screw on the switch. 

If there is no ground wire, but the box is metal, you should connect a ground wire from the switch to a screw put into one of the threaded holes in the back of the box, or use a ground clip placed on the edge of the box.

If there is no ground wire and the box is plastic, you can ignore it.