This is a little trick I picked up sometime ago. It really comes in handy when your trying to hang those tricky items...you know the ones with holes on the left and right...I can't tell how many holes I have put in the wall before learning this little trick.
Step 1. Place a piece of tape across holes from left to right
Step 2. Poke hole in tape, marking where your screws will go....
Step 3. Carefully remove tape from shelf and place it on the wall where you'd like to hang your shelf.
This would be a good time to use a level to make sure your tape is straight.
Step 4. Place screws through your mark in the tape.
Step 5. Remove tape
Step 6. Push shelves onto screws and viola'...a perfectly hung shelf.