Background: Family medicine (FM) residents and medical and nursing students play an important role in the development of preventive and health-promoting activities. Objective: To evaluate the health-related lifestyles and cancer-preventive behaviors of medical and nursing students and FM residents in relation to the European Code Against Cancer (ECAC). Methods: This was a descriptive, cross-sectional study performed in Spain. Medical and nursing students, and FM residents completed a self-administered questionnaire focused on health-related habits and clinical behaviors related to the ECAC. Results: A total of 740 participants completed the questionnaire. 12.2% (95% CI [9.8-14.5]) were smokers and 77.3% (95% CI [74.3-80.3]) sporadically consumed alcohol; 34.2% (95% CI [30.8-37.6]) practiced physical activity 2-3 times a week, and 12.1% (95% CI [9.8-14.5]) were overweight or obese. 54.2% (95% CI [50.6-57.8]) regularly consumed vegetables. Differences were detected in the completion of screening tests for colorectal cancer (p < 0.001), breast cancer (p = 0.023), cervical cancer (p = 0.006), and prostate-specific antigen determination (p < 0.001) in relation to the participants' academic profiles. Conclusion: Our results reveal heterogeneous practices between the participants in terms of health-related habits. Awareness about the risks of smoking and being overweight were high, however, the perception of the risks associated with solar exposure and alcohol consumption was poor. There was general agreement upon the importance of performing screening tests for breast, cervical, and colorectal cancer, but there were discrepancies related to the need to perform the prostate cancer screening test.