the chlorine atom bonds through covalent bond to obtain an octet structure so two atoms of 2,8,7 come together and HCl consists of both metal and nonmetal which is the the covalent bonding principle so H and Cl share the 8 valence electrons to obtain an octet structure.