A caterpillar is a tree in which all vertices of degree three or more lie on one path, called the backbone. We present a polynomial time algorithm that produces a linear arrangement of the vertices of a caterpillar with bandwidth at most O(logn/loglogn) times the local density of the caterpillar, where the local density is a well known lower bound on the bandwidth. This result is best possible in the sense that there are caterpillars whose bandwidth is larger than their local density by a factor of Ω(logn/loglogn). The previous best approximation ratio for the bandwidth of caterpillars was O(logn). We show that any further improvement in the approximation ratio would require using linear arrangements that do not respect the order of the vertices of the backbone. We also show how to obtain a (1 + ²) approximation for the bandwidth of caterpillars in time 2˜ O(√n/²). This result generalizes to trees, planar graphs, and any family of graphs with treewidth ˜ O(√n).