If the supply voltage is higher than the LED's voltage, the resistor has to be included in the circuit in series. The resistor limits the current and produces the required voltage drop. To find the correct value for the resistor, the following equation is derived from Ohm's law:
R = (Uin - Uf) / If
Ur = Uin - Uf
Pr = Ur ⋅ If
where:
The current limiting resistor of an LED has to be not smaller than R, and at least with the power of Pr.