The halogen in period 3 will be having 7 electrons in the outermost third shell. This must require one electron for its octet to be completed. So, each of its atoms needs to make bond with one hydrogen atom which donates its one electron and hence, the formula HX.