Defence against predators

For most animals, defence against predators is vital. Being eaten is not the only threat to life: parasites and diseases may also be fatal. But many animals are carnivores, and others, especially small animals, are often eaten. 
Since life is about reproduction, anything that keeps a creature alive long enough for it to reproduce will be selected for. The next generation comes from the fertilised eggs of the previous generation.
Not surprisingly, then, animals have developed a wide range of defences against predation. Some of these defences apply also to plants: herbivory on plants can be very damaging, and reduce a plant's fertility. Many plants have some defence against herbivores.
Primary defences.
Primary defences make it less likely that there will be a meeting between the predator and the prey. In many cases this means the predator has not noticed or recognised the prey.
Definitions.
There are various definitions of what a primary defence is:
Methods.
For palatable prey.
If the prey is good to eat, it must either make itself scarce, or it must look as though it is not good to eat. A third possibility is that the prey is too small to bother with. In other words, the effort of catching and eating it would not be worth the effort expended by the predator.
For prey with defences.
Defences may be of two kinds. Either the prey is uneatable because it has some kind of chemical defence, or its body is protected by spines or stings. In that case the predator will reject it so long as the prey advertises its defence.
The second kind of defence is very obvious. It is to carry armour and/or offensive weapons like horns. These are permanent visible defences. For larger prey animals this can be effective if linked to another defence. Thus, in natural habitats, elephants have tusks, and they also have huge size. Antelope have horns, and can also run fast. Almost all large herbivores live in herds, which undoubtedly is safer than living alone.
Secondary defences.
These work when a predator detects a prey, or when a prey notices a predator. The function of secondary defences is to increase the chance of the prey surviving the encounter (meeting).
Costs of defence.
Everything costs something. All defences incur costs. For survival, an animals needs food, and needs to stay alive to reproduce. Energy and time spent on defence can be considerable, but justified if it makes reproduction more likely. There are these kinds of costs: