Both genetic and lifestyle factors were independently associated with early-onset total and breast cancer risk. Compared to those with low genetic risk, individuals with a high genetic risk may benefit more from adopting a healthy lifestyle in preventing early-onset cancer.