Electromagnetic and mechanical waves differ in that electromagnetic waves are always longitudinal and do not require a known medium, while mechanical waves are either longitudinal or compression waves and require a medium. All known electromagnetic waves are also known as forms of light. An example of a longitudinal mechanical wave is a wave in water, while sound is an example of a compression wave.
Electromagnetic waves are actually created by the oscillations of electric and magnetic fields at right angles to each other. Electromagnetic waves move faster than any known mechanical wave. Electromagnetic waves tend to travel fastest through a vacuum. They travel slower through other materials, with their speed being inversely proportional to the density of the material.
This stands in stark contrast to mechanical waves, which often travel faster the denser their medium is. Longitudinal waves cause their medium to oscillate at a right angle to the wave's direction of travel. Compression waves cause the medium to oscillate in the direction of travel, creating areas of higher or lower density. Compression waves propagate more quickly through dense or solid materials, in particular, with sound traveling relatively slowly through air, faster through water and extremely quickly through a solid such as iron.