Different types of substances can combine in many different ways. Some substances react chemically with one another when they come into contact, recombining to form other substances. Two classes of substances that combine readily, and sometimes violently, are acids and bases.
To understand the chemical behavior of acids and bases, we have to begin with water. Water molecules consist of two hydrogen atoms and one oxygen atom (HOH). In liquid water, some of these molecules come apart to form two kinds of ions: positive hydrogen ions (H+) and negative hydroxide ions (OH-). In water, there are equal numbers of hydrogen and hydroxide ions, because every molecule that comes apart produces one of each type.
An acid is a solution of a chemical in water that results in more H+ ions than OH- ions. A base is a solution of a chemical in water that results in the opposite: more OH- ions than H+ ions.
When acidic and basic solutions are combined, the H+ ions from the acid and the OH- ions from the base combine to form water molecules. At the same time, other ions, which formed when the H+ and OH- ions were first produced, combine to form new molecules, such as salts and/or gases. The type of molecules formed depends on the makeup of the chemicals initially combined.
Many natural substances are good acid-base indicators. For example, a solution made from the pigment of red cabbage varies in color from deep red when exposed to a strong acid to yellowish green when exposed to a strong base. The details of why various chemicals produce molecules that absorb different wavelengths of light and are therefore of different colors are complex and varied.