How do you know if a Canon lens is an EF lens?

An EF (Electro-Focus) lens will have a marking on the barrel that designates its brand, lens type, focal length, aperture and miscellaneous features. An example: Canon Lens EF 40mm 1:2.8 STM

EF Lens will also have a red dot at the rear of the lens near the mount that is used to align the lens with a red dot on the camera's mount. EF-S (Electro-Focus Short) lenses will have a white square in place of a red dot.