We review physically-motivated studies of bacterial near-surface motility driven by flagella and type IV pili (TfP) in the context of biofilm formation. We describe the motility mechanisms that individual bacteria deploying flagella and TfP use to move on and near surfaces, and discuss how the interactions of motility appendages with fluid and surfaces promote motility, attachment and dispersal of bacteria on surfaces prior to biofilm formation.