Mechanical waves are those waves that needs certain medium for its propagation in any direction.
Ocean wave cannot travel if there is no channel like water. Similarly sound waves cannot travel in vacuum i.e. it needs medium to propagate. Hence they are mechanical waves.
Light do not need any form of medium, it can propagate in empty space too. So x-rays, infrared radiation are electromagnetic wave.