Dietary habits have considerable impact on brain development and mental health. Despite long-standing interest in the association of dietary habits with mental health, few population-based studies of dietary habits have assessed depression and fluid intelligence. Our aim is to investigate the association of dietary habits with depression and fluid intelligence. In total, 814 independent loci were utilized to calculate the individual polygenic risk score (PRS) for 143 dietary habit-related traits. The individual genotype data were obtained from the UK Biobank cohort. Regression analyses were then conducted to evaluate the association of dietary habits with depression and fluid intelligence, respectively. PLINK 2.0 was utilized to detect the single nucleotide polymorphism (SNP) × dietary habit interaction effect on the risks of depression and fluid intelligence. We detected 22 common dietary habit-related traits shared by depression and fluid intelligence, such as red wine glasses per month, and overall alcohol intake. For interaction analysis, we detected that OLFM1 interacted with champagne/white wine in depression, while SYNPO2 interacted with coffee type in fluid intelligence. Our study results provide novel useful information for understanding how eating habits affect the fluid intelligence and depression.