It is common, in both theoretical and experimental studies, to separately discuss quark and gluon jets. However, even at parton level, widely-used jet algorithms fail to provide an infrared safe way of making this distinction. We examine the origin of the problem, and propose a solution in terms of a new "flavour-kt" algorithm. As well as being of conceptual interest this can be a powerful tool when combining fixed-order calculations with multi-jet resummations and parton showers. It also has applications to studies of heavy-quark jets.