The force–extension relation for a semiflexible polymer confined in a nanoslit is investigated. Both the effective correlation length and force–extension relation change as the chain goes from 3D (large slit heights) to 2D (tight confinement). At low forces, correlations along the polymer give an effective dimensionality. The strong force limit can be interpolated with the weak force limit for two regimes: when confinement dominates over extensile force and vice versa. These interpolations give good agreement with simulations for all slit heights and forces. We thus generalize the Marko-Siggia force–extension relation for DNA and other semiflexible biopolymers in nanoconfinement.