In a triple slit optical encoder, a first grating and a third grating are formed on separate members, and values of a first effective width W1 and a first pitch p1 of an optical pattern on the first grating, and a third effective width W3 and a third pitch p3 of an optical pattern on the third grating are set to values such that a periodic signal having the amplitude effective for detection of a relative displacement of a scale is achieved based on periodicity of the self-image, refractive indices of substances of substances and / or spaces interposed in the optical path from a bare LED up to a photodetector, and the thickness of those substances and / or spaces in a direction substantially perpendicular to a plane on which the second grating is formed.