The inhibition performance of ionic liquids, abbreviated as [(CH2)COOHMIm][HSO4], [(CH2)2COOHMIm][HSO4], and [(CH2)3SO3HMIm][HSO4] was investigated for carbon steel in 0.5 M HCl solution. Results indicated that these ionic liquids could act as effective inhibitors by adsorption onto the steel surface, and the inhibition efficiency increases with cation alkyl chain length and concentration up to a limit. The inhibition efficiency of a sulfonate-type ionic liquid with a longer alkyl chain is higher than those of the carboxylate-type ionic liquids. Besides, the order of inhibition efficiency was verified by both computational calculation and electrochemical experimental observations.