We study the scaling properties of critical particle systems confined by a potential. Using renormalization-group arguments, we show that their critical behavior can be cast in the form of a trap-size scaling, resembling finite-size scaling theory, with a nontrivial trap critical exponent theta, which describes how the correlation length xi scales with the trap size l, i.e., xi approximately l;{theta} at T_{c}. theta depends on the universality class of the transition, the power law of the confining potential, and on the way it is coupled to the critical modes. We present numerical results for two-dimensional lattice gas (Ising) models with various types of harmonic traps, which support the trap-size scaling scenario.