The key to trimming your dog's toenails is to avoid cutting the quick, the live tissue where the blood vessels and nerves are (ie. the thing that bleeds if you cut the nails too short).
Locate the shadow of the quick inside light colored toenails and trim no closer than an eighth of an inch. Black nails require extra caution because it's difficult to see the quick inside them.
If you don't have medi styptic powder on hand and you happen to cut the nail too short you can try flour for a quick fix.