Since it would be impossible to turn you into an electrician in a single answer, I'll recommend some reading.
For the US, home wiring is governed by the NEC (National Electrical Code). It's a huge, detailed, expensive publication. For a DIYer, I strongly recommend purchasing the most recent edition of Wiring Simplified. It's probably available at your local (or big-box) hardware stores (I've seen it at Ace Hardware and Home Depot), or here on Amazon, should be around $10. I use it when planning any electrical job at my house, parents' cottage, or workshop.
From the Amazon description:
Revised and completely updated for the
2008 National Electric Code, this
small manual continues its 75-year
history of demonstrating how to
install safe, convenient, and
economical wiring. Encouraging readers
to tackle jobs small and large, the
guide covers everything from repairing
a table lamp to wiring a whole house.
After introducing the
basics—standards, codes, safety
practices, and an overview of how
electricity is measured and
delivered—chapters show how to design
a layout for lights, switches, and
receptacles; run a line from a utility
pole; install wires, circuits, and
grounds; and handle special projects
such as replacing old wiring and
wiring detached garages and accessory
There is a section on safety, and the book recommends good practices, but it's not a replacement for training. It's a good reference for knowing what you're working with, though, and common-sense rules (like the one-hand rule, disconnecting the breaker, and wearing rubber-soled shoes) together with this book will make you a much better electrician.