We study and demonstrate the technique of simultaneous spatial and temporal focusing of femtosecond pulses, with the aim to improve the signal-to-background ratio in multiphoton imaging. This concept is realized by spatially separating spectral components of pulses into a "rainbow beam" and recombining these components only at the spatial focus of the objective lens. Thus, temporal pulse width becomes a function of distance, with the shortest pulse width confined to the spatial focus. We developed analytical expressions to describe this method and experimentally demonstrated the feasibility. The concept of simultaneous spatial and temporal focusing of femtosecond pulses has the great potential to significantly reduce the background excitation in multiphoton microscopy, which fundamentally limits the imaging depth in highly scattering biological specimens.