Danmaku is increasingly used during online interactions - such as learner communication in online learning. As an emerging online interaction method, Danmaku not only enhances the viewer interaction experience, but also allows learners to achieve better learning outcomes. Therefore, this study used a 2 (Danmaku font size: large, small) × 2 (cognitive style: field-independent, field-dependent) between-participants design to investigate the effect of Danmaku font size on online learning through eye-tracking studies and to reveal the mechanism of the effect of Danmaku font size on the learning outcomes of field-independent and field-dependent learners. The results show that Danmaku font size affects the learning perception of learners with different cognitive styles in online learning, i.e., under the field-independent cognitive style, small font Danmaku can improve the online learning perceptual experience. Under the field-dependent cognitive style, learners focus more on the Danmaku area, so the Danmaku with large font size can improve the online learning perceptual experience. In summary, this study found that the Danmaku font size impacts the online learning effect of learners with different cognitive styles. Therefore, different Danmaku font sizes should be selected according to different cognitive styles during online teaching. This study can provide research basis and optimization suggestions for how to use Danmaku in online teaching design, which will help deepen the understanding of the role of Danmaku in online teaching.