Yes, you can use any lens with an EF or EF-S mount type on the EOS 400D.
However, if you put an EF on the 400D, you have to convert the focal length. Canon's conversion factor for the so-called APS-C sensors is 1.6.
So the EF 50mm on the 400D effectively has a focal length of 80mm.
Lenses with EF-S mount are made exactly for APS-C sensors. You don't have to convert anything there either.