So if you wish to create a transverse wave in a slinky, then the first coil of the slinky must be displaced in a direction perpendicular to the entire slinky. Similarly, if you wish to create a longitudinal wave in a slinky, then the first coil of the slinky must be displaced in a direction parallel to the entire slinky. Electromagnetic waves are produced by the vibration of electrons within atoms on the Sun's surface. These waves subsequently travel through the vacuum of outer space, subsequently reaching Earth. Were it not for the ability of electromagnetic waves to travel to Earth, there would undoubtedly be no life on Earth.
All light waves are examples of electromagnetic waves.
Light waves are the topic of another unit at The Physics Classroom. While the basic properties and behaviors of light will be discussed, the detailed nature of an electromagnetic wave is quite complicated and beyond the scope of The Physics Classroom. A mechanical wave is a wave which is not capable of transmitting its energy through a vacuum. Mechanical waves require a medium in order to transport their energy from one location to another. A sound wave is an example of a mechanical wave.