  We observed the young ($\sim 1700$ yrs) pulsar PSR B0540-69 in the
near-ultraviolet (UV) for the first time with the Space Telescope Imaging
Spectrograph (STIS) aboard the {\em Hubble Space Telescope}. Imaging
observations with the NUV- and FUV-MAMA detectors in TIME-TAG mode allowed us
to clearly detect the pulsar in two bands around 2350\AA\ and 1590\AA, with
magnitudes $m_{\rm NUV} =21.449 \pm 0.019$ and $m_{\rm FUV} =21.832 \pm 0.103$.
We also detected the pulsar-wind nebula (PWN) in the NUV-MAMA image, with a
morphology similar to that observed in the optical and near-infrared (IR). The
extinction-corrected NUV and FUV pulsar fluxes are compatible with a very steep
power law spectrum $F_{\nu} \propto \nu^{-\alpha}$ with spectral index
$\alpha_{\rm UV} \sim 3$, non compatible with a Rayleigh Jeans spectrum,
indicating a non-thermal origin of the emission. The comparison with the
optical/near-IR power-law spectrum (spectral index $\alpha_{\rm O,nIR} \sim
0.7$), indicates an abrupt turn-off at wavelengths below 2500 \AA, not observed
in other pulsars. We detected pulsations in both the NUV and FUV data at the 50
ms pulsar period. In both cases, the pulse profile features two peaks closely
spaced in phase, as observed in the optical and X-ray light curves. The NUV/FUV
peaks are also aligned in phase with those observed in the radio (1.4 GHz),
optical, X, and $\gamma$-ray light curves, like in the Crab pulsar, implying a
similar beaming geometry across all wavelengths. PSR B0540-69 is now the fifth
isolated pulsar, together with Crab, Vela, PSR\, B0656+14, and the radio-quiet
Geminga, detected in the optical, near-UV, near-IR, X-rays and $\gamma$-rays,
and seen to pulsate in at least four of these energy bands.
