Fluorescent carbon nanomaterials have attracted increasing attention owing to their unique photoluminescence properties, good biocompatibility and low toxicity in bioimaging as well as biosensing. Heteroatom doping is usually used to improve photoluminescence properties by tuning the functional groups and the particle size domain effect, thus leading to redshifted emission. Here, we report a straightforward strategy for the fabrication of a mixture of fluorescent phosphorus and nitrogen carbon nanodots (P,N-CDs) followed by separating two kinds of fluorescent fractions based on their different negative charges. Such a one-pot hydrothermal method using formamide, urea and hydroxyethylidene diphosphonic acid as the precursor yields fluorescent P,N-CDs. Specifically, blue-emitting CDs (bCDs) and green-emitting CDs (gCDs) were separated by using column chromatography. The quantum yields of bCDs and gCDs were 20.33% and 1.92%, respectively. And the fluorescence lifetimes of bCDs and gCDs were 6.194 ns and 2.09 ns, respectively. What is more, the resultant P,N-CDs exhibited low toxicity and excellent biocompatibility. Confocal fluorescence microscopy images were obtained successfully, suggesting that P,N-CDs have excellent cell membrane permeability and cellular imaging. This work provides a promising fluorescent carbon nanomaterial with tunable emission as a probe for versatile applications in bioimaging, sensing and drug delivery.