Please no hate for lack of knowledge:

I am somewhat fascinated with the subject of black holes. However, I do not understand a concept which is constantly attributed with black holes: that a black hole can attract light and therefore light cannot escape it. What I don't understand is, how? Gravity, as far as I understand, only attracts matter. However, light has no mass (right?), so how can a black hole attract light?