Electrical Wire Markings
Electrical wires have markings stamped or printed on the outside sheath of the cable. These markings tell what type and size of wire that you have. But looking deeper, the color of the wires inside of the sheath, like in type NM cable, will reveal that different color wires serve different purposes.
Black wires are always used for hot wires. These wires may feed a switch or outlet and are often used as switch legs. Never used a black wire for a neutral or ground connection.
Red wires are also used for hot wires, switch legs (like to a ceiling fan), and are the second hot wire in 220-volt installations. Another useful application is the interconnect wire between two hardwired smoke detectors.
Blue and Yellow Wires
Blue and yellow wires are used as hot wires. These wires are usually pulled in conduit. The blue wires are generally used for travelers in three-way and four-way switch applications. They also are used as switch legs to things like lights and fans. Yellow wires are generally used for switch legs. These control things like light, fans, and switched outlets.
Green and Bare Copper Wires
Green wires and bare copper wires are used only for grounding. These wires will ground devices and shall be bonded to junction boxes and appliance connections for safety.
Wire Color Exceptions
In certain instances, wire colors may be used for connections that don't follow these general rules. For instance, a white wire in a two-conductor cable may be used for the second hot wire on a 240-volt appliance or outlet connection. Another application is using the white wire for a switch leg for lighting or running a three-way switch application. This white wire should be properly marked to show that it is being used for something other than a neutral. Simply mark the end of the wire with black or red electrical tape. That way, no one will be confused and accidentally use it for something else.