Your question is a reminder that we usually don't teach this material in a clear way. The relation E=hf
holds, so far as we know, for everything in the universe. E
here is the energy, f
is the frequency of the changes in the quantum state, and h
is Planck’s constant. For photons, f also gives the frequency of the changes in the standard EM fields. This relation is part of quantum mechanics, and not so directly connected to SR. h
is a general constant of the universe, not connected to any particular type of particle.
Where SR comes into play is in determining how E depends on momentum for different types of particles, such as the massless ones you mention or massive ones like electrons or atoms. You could search around this site for discussions of that relation, or ask a follow-up if you wish.
(published on 10/22/2007)