It is important that you know what each color represent in electrical wire color codes. Failure to follow the electrical wire color codes puts you at risk of electric shock, which could be fatal. Understanding what the different colors mean will also help you prevent damage to electrical appliances and the wiring system.
The 1st electrical code in the U.S. was put in place in 1881 in New York. The U.S. National Fire Protection Association, which is a non-profit association by insurance companies, published the NEC (National Electrical Code) in 1897. The code is modified every 3 years, with suggestions from committees of tradesmen, engineers, fire fighters, manufacturing reps, and other invitees being considered. Note that electrical wire color codes are different in different countries. There has been harmonization of the Canadian Standards Association (CSA) and NEC, an initiative of the NAFTA (North American Free Trade Agreement) program.
Under the NEC, black, orange (high leg delta), and red insulated wires are phase wires in a circuit. Note that some other colors might also be used, but never gray, white, or green, whether these are stripped or solid colors. Note that there are specific exceptions, one such exception being cable running to switches and back (or travelers) where white wires are used as the hot wires feeding the switch. Yet another exception is cables that feed outlets for 250VAC 15 or 20 amp appliances where neutral wires are not required. In such applications, white wires are hot (there has to be indication of this with black tape inside the junction box).
White or grey insulated wires are neutral wires. Markings or stripes could be used for the wires. In lamp cord wires, the ribbed wires are the neutral wires while the smooth wires are the hot wires. Under NEC2008 400.22(f), you could have grooves, white stripes, or ridges as surface marking of lamp cord. In the case of transparent lamp cords, the silver cored wires are the neutral wires while the copper colored wires are the hot wires.
Green wires, wires with green stripes, or bare wires are ground wires under the NEC color code. Note that all metallic systems, including HVAC piping, natural gas piping, and water piping, should be grounded on the building's grounding system to reduce the risk of electric shock and electric damage. Larger wires only come in black. They should also be properly identified with tape or paint. For the on-the-wall and behind-the-wall wiring cables, the colors for phases, neutral, and ground are black, red, and blue (120/208/240V) (brass) respectively.
It is also important that you know the electrical wire color codes of other countries as you will be on the safe side when outside the U.S. and when you buy an electrical item that is manufactured outside the U.S. Whenever you see a black wire, know that it is a hot wire. The wire could feed an outlet or a switch. Black wires are usually used as switch legs. Never use the wire for ground or neutral connections. Red wires are used as hot wires, second hot wire in installations of 220 volts, and as switch legs (in the likes of ceiling fans). Yellow and blue wires are hot wires. The wires are usually pulled in conduit, with the blue wire usually used for travelers in 3-way or 4-way switch applications. The blue wires are also used for as switch lets in fans and lights. On the other hand, yellow wires are mostly used for switch legs to control such things as switch outlets, fans, and lights.
In most electrical wire color codes, bare copper and green wires are exclusively used for grounding. There are several exceptions. In 2-conductor cables, white wires are used as 2nd hot wires on outlet connections or 240-volt appliances. White wires are also used to run 3-way switch applications and as lighting switch legs. When not being used as neutral, there should be special markings indicating this. Simply mark the end with red or black.