An 8-speed chain will also work perfectly for 6- and 7-speed bikes. I'm assuming that by 12-speed, your bike has six gears on the rear.
A 5-speed chain will be too wide to work properly. A 9-, 10, or 11-speed chain would be too narrow and could fall between the gears as Andrew mentions.