it is formed when the element chlorine gains an electron or when a compound such as hydrogen chloride is dissolved in water