I'm about to modify my photovore to also give it line following ability, and have a couple of questions. Specifically a black line on white background.
Well, it depends...
Get a datasheet for the specific LDR in question and find its peak sensitivity relative to wavelength (look for a curve or in the description).
This will be the optimum wavelength (/"color") to use.That only counts as long as the peak wavelength is within the visible range however, as both UV and IR may make a "color" (black and white are not colors) like black be quite a different color to the detector, depending on material or whatever coating may be used - eg. some black plastics are the new white when under IR.
Your LDR will most likely peak between 500nm and 580nm and many is close to 550nm (a slightly yellowish green), so this is more for when you upgrade to silicon detectors some day.
White LEDs are not really shining white, it's our eyes (or rather our brain) that gives us that impression.
Study them in a spectroscope and they will show their main output as very narrow peaks of blue and yellowish.
The exception being RGB-founded white LEDs, which has got 3 narrow peaks of course, red, green and blue and as you probably know, we
see a mix of red and green as yellow, detectors don't.Always remember that your eyes and the different types of light sensors are very different receptors and that what you see is not necessarily (seldom actually) what the sensors see.
If your LDR is a typical ~550nm (or thereabout) peak device, get one of the so called "True Green" ("Super Green") high brightness LED to experiment with. As this is close to our own peak sensitivity, they'll appear brighter than other colors to us as well. (Some of the True Green LED's in my possession can even be used for a torch at night on less than 20mA because of that)
1) What is the best colour LED to use to shine onto the floor, white, red or what - infra-red?
Answered above, but don't be afraid to experiment.
Further... LED's come in a multitude of half angles (the angle where the intensity is half that at the center of the core) and if you see a narrow angle LED with a huge mCd-rating, don't be surprised, as the angle narrows, the light intensity goes up with the square of the change in angle, so quite often, you can find an LED with a lower mCd-value having more light output than a narrow beam LED with a huge number - to compare them, you have to convert the mCd @ nn° to eg. lumen, which will give one directly comparable number.
Go for the angle you need, not much more or less. You find that from measuring the distance from the point in the LED where the semiconductor crystal is placed in the LED to the floor, the are that you want to cover with the core of the light beam and a bit of trigonometry.
If you're using a number of LED's to make what looks like a bar of light to you, once again, detectors will see this, more or less, as spots of light, even if it looks like a solid bar to you, so test thoroughly with all detectors used and on both white and black - the very same that you're gonna run the finished 'bot on if at all possible.
2) Is it best to have the LED in front of the LDR (the direction it is travelling), or to the side?
As long as the kernal of the light beam is covering all that you allow the LDR to see (use tubing to cut down the angle) and if the LDR's doesn't see too much ambient light, it doesn't matter, but mechanically, it may be best to mount them in a certain way, depending on how you built the rest of the 'bot.
3) If to the side, should the LED be inside or outside the LDR?
Again, it doesn't matter, as long as the core of the light covers the angle of "vision", but a close by position is best, since it gives the most reflected light and the more of the wanted light, the more ambient is swamped out.
4) Should the LDR be slightly closer to the floor than the LED, or vice versa?
The LDR should be slightly closer to the floor and mounted in a tube covered with opaque stuffTM
so that it won't get any light at all from its backside.
If you do it the other way around, you risk the LDR "seeing" the LED rather than it's reflected light (depending on how you build it all of course).