Color of chemicals. The color of chemicals is a physical property of chemicals that in most cases comes from the excitation of electrons due to an absorption of energy performed by the chemical.

The study of chemical structure by means of energy absorption and release is generally referred to as spectroscopy.

Theory 

All atoms and molecules are capable of absorbing and releasing energy in the form of photons, accompanied by a change of quantum state. The amount of energy absorbed or released is the difference between the energies of the two quantum states. There are various types of quantum state, including, for example, the rotational and vibrational states of a molecule. However the release of energy visible to the human eye, commonly referred to as visible light, spans the wavelengths approximately 380 nm to 760 nm, depending on the individual, and photons in this range usually accompany a change in atomic or molecular orbital quantum state. The perception of light is governed by three types of color receptors in the eye, which are sensitive to different ranges of wavelength within this band.

The relationship between energy and wavelength is determined by the Planck-Einstein relation
 
where E is the energy of the quantum (photon), f is the frequency of the light wave, h is the Planck constant, λ is the wavelength and c is the speed of light.

The relationships between the energies of the various quantum states are treated by atomic orbital, molecular orbital, Ligand Field Theory and Crystal Field Theory. If photons of a particular wavelength are absorbed by matter, then when we observe light reflected from or transmitted through that matter, what we see is the complementary color, made up of the other visible wavelengths remaining. For example, beta-carotene has maximum absorption at 454 nm (blue light), consequently what visible light remains appears orange .

Colors by wavelength 
What is seen by the eye is not the color absorbed, but the complementary color from the removal of the absorbed wavelengths. This spectral perspective was first noted in atomic spectroscopy.

Below is a rough table of wavelengths, colors and complementary colors. This utilizes the scientific CMY and RGB color wheels rather than the traditional RYB color wheel.

This can only be used as a very rough guide, for instance if a narrow range of wavelengths within the band  is absorbed, then the blue and green receptors will be fully stimulated, making cyan, and the red receptor will be partially stimulated, diluting the cyan to a greyish hue.

By category 
The vast majority of simple inorganic (e.g. sodium chloride) and organic compounds (e.g. ethanol) are colorless. Transition metal compounds are often colored because of transitions of electrons between d-orbitals of different energy. (see Transition metal#Colored compounds). Organic compounds tend to be colored when there is extensive conjugation, causing the energy gap between the HOMO and LUMO to decrease, bringing the absorption band from the UV to the visible region. Similarly, color is due to the energy absorbed by the compound, when an electron transitions from the HOMO to the LUMO. Lycopene is a classic example of a compound with extensive conjugation (11 conjugated double bonds), giving rise to an intense red color (lycopene is responsible for the color of tomatoes). Charge-transfer complexes tend to have very intense colors for different reasons.

Examples 

However, elemental colors will vary depending on what they are complexed with, often as well as their chemical state.  An example with vanadium(III); VCl3 has a distinctive reddish hue, whilst V2O3 appears black.

Salts 
Predicting the color of a compound can be extremely complicated.  Some examples include:
 Cobalt chloride is pink or blue depending on the state of hydration (blue dry, pink with water) so it is used as a moisture indicator in silica gel.
 Zinc oxide is white, but at higher temperatures becomes yellow, returning to white as it cools.

Ions in flame

Gases

Bead tests 

A variety of colors, often similar to the colors found in a flame test, are produced in a bead test, which is a qualitative test for determining metals. A platinum loop is moistened and dipped in a fine powder of the substance in question and borax. The loop with the adhered powders is then heated in a flame until it fuses and the color of the resulting bead observed.

References 

Chemical properties