Transition metals can form colored compounds when bonded to other elements due to the energy levels of the d block where electrons can be excited and move between energy levels.