Although the use of enclosed learning space appears to influence both attention and learning in undergraduates, this issue has rarely been investigated. This study used four types of desktop spaces with different degrees of enclosure, namely, unenclosed, enclosed on one side, enclosed on two sides and enclosed on three sides, with enclosure degrees of 0, 25, 50 and 75%, respectively. Subjective evaluations, attention tests and eye tracking were used to analyze the effects of the four types of enclosure on attention in 38 undergraduates. Subjective evaluations showed that the three-sided enclosure was favoured by 52.63% of the undergraduates, 84.21% of which considered that it contributed to improved attention. The objective data showed that quiz times were shortened by 25.95% in unenclosed spaces compared with 75%-enclosed spaces, with increases in the mean pupil diameter, area of interest attention and target fixation rate of 11.36, 8.15 and 6.89%, respectively. These results indicated that the attention level increased in correspondence with the degree of enclosure of the learning space and that highly enclosed spaces were more conducive to attention and learning in undergraduates. This suggests that relatively closed spaces should be recommended to learning institutions to improve the learning efficiency of undergraduates.