You can use this LED Calculator. Enter the parameters and it will calculate the proper size resistor and draw the circuit. In your case:
Power supply Voltage=18v, LED Voltage drop 3v, LED current rating 20ma (usual choice for a good balance in light brightness and longevity): Resistor size will be 750 Ohm, 1/2 watt.
If you want it a little dimmer (Current=15ma), the resistor will be 1K 1/4 watt.
Other considerations:
If you are using multiple LEDs, wire them in series, and you can use lower wattage resistors and less power would be wasted as heat. The LED Calculator allows you to enter the number of LEDs up to the maximum the supply voltage can light.
LEDs can be powered with DC voltage with only the LED and a resistor in series. If you are using AC voltage, you should use a diode (1N4001, 1N4002, 1N4003, etc) in series with the LED and resistor to protect the LED from reverse voltage. Alternatively, you can use 2 LEDs in parallel (opposite polarity) in series with one resistor (only enter one LED in the LED calculator in this instance). Multiply the AC voltage (RMS voltage) by 1.4 to get the AC peak voltage, and use that figure in the LED Calculator.
Bob