The face-to-face survey was conducted from June to August 2017, collecting data on sociodemographic characteristics, HIV-related knowledge, attitudes towards homosexuality and practice of sexual behaviours among Chinese senior high school and university students. A generalised linear model (GLM) was used to assess the different levels of HIV knowledge between groups, and identify the key contributors to HIV knowledge scores. The survey was completed by 73.6% (1355/1840) of the students approached. The overall level of HIV-related knowledge was low (58.9%, 10.6/18); 48.0% (650/1355) supported same-sex marriage; and 6.9% (93/1355) self-identified as homosexual or bisexual. The major factors associated with higher scores [mean ± standard deviation (s.d.)] in HIV knowledge among students included: having received school-based HIV education (11.47 ± 3.51 vs 9.02 ± 4.14, P < 0.05); support for same-sex marriage (11.69 ± 3.33 vs 9.49 ± 4.29, P < 0.05) and older age (11.61 ± 2.78 vs 9.87 ± 4.17, P < 0.05). Compared with females, males were significantly more likely (all P < 0.05) to report masturbation (60.7% vs 7.6%), pornography experiences (77.4% vs 35.3%), sexual encounters (24.6% vs 12.3%), casual sex (37.0% vs 18.1%) and sex under the influence of alcohol (29.5% vs 12.8%). There is is still much room for improvement in terms of HIV/AIDS prevention and health education for Chinese young people, and more comprehensive and diverse models of education for HIV prevention are urgently needed.