You determine the voltage drop that you want across the resistor and the current flowing through it. From that you calculate its value from the equation R = V / I
For example, say you have a 12 volt supply to power an LED that requires 25mA and has a forward voltage of 1.8volts. By using a resitopr in series with the LED you can set the correct operating parameters.
Since the resistor is in series with the LED, the same 25mA flows through it. The resistor is required to develop 10.2 volts across itself
(12 - 1.
So R = 10.2 / 0.025 = 408 ohms. For general applications one chooses a resistor value from a standard selection range. In this case our choice is 390 ohms or 470 ohms. 390 would entail more current flowing through the LED, which may damage it. One cannot determine exactly how much more since the LED is a non-linear device. So one would select the more conservative 470 ohm. This would mean less current flowing so the LED would be somewhat (slightly) dimmer.
Resistor power rating, based on the original calculated value is W = V x I which is 10.2 x 0.025 = 0.255 watts. Since we are using a larger value value which will mean a reduced current it is reasonable to use this vale for component selection. However, one should run components at lower than their rated value (for enhanced life) so either a 1/3rd or 1/5 watt unit should be chosen.