We investigated the physical and chemical stabilities of sulfur and phosphorus molecules encapsulated in a mesoporous carbon (MPC) and two kinds of single-walled carbon nanotubes (SWCNTs) having different cylindrical pore diameters. The sublimation temperatures of sulfur molecules encapsulated in MPC and the two kinds of SWCNTs were measured by thermo-gravimetric measurements. It was found that the sublimation temperature of sulfur molecules encapsulated in SWCNTs having mean tube diameter of 1.5 nm is much higher than any other molecules encapsulated in larger pores. It was also found that the capacity fading of lithium-sulfur battery can be diminished by encapsulation of sulfur molecules in SWCNTs. We also investigated the electrochemical properties of phosphorus molecules encapsulated in SWCNTs (P@SWCNTs). It was shown that P@SWCNT can adsorb and desorb both Li and Na ions reversibly.