Each butterfly lays its eggs only on certain plants, because its caterpillars cannot eat others: the swallowtail on fennel, dill or carrot; the peacock and red admiral on nettles; the cabbage white on brassicas.
A butterfly garden needs both: nectar flowers for the adults and host plants for the caterpillars. Without the latter, the butterflies pass straight by.

