It even happens in the hot magma inside the earth. Hot air, hot water, and hot rock all tend to rise. Cold creeps lower. Cold air, cold water, and cool rock all tend to sink. Space is so empty that there is not much matter to warm up.
Heat travels by radiation .
Heat waves travel out into the void. When they strike matter, they make the matter warmer. Heat is only a part of what it emits. The sun also emits light, radio waves, gamma radiation, ultraviolet and infrared radiation. Elizabeth Anne Viau.