Just to make a small correction to the above, in a traditional diesel engine it is solely air which is compressed then fuel is injected and immediately self-ignited.
To add, the demarcation between the workings of petrol and diesel engines has become a bit blurred in recent times, since there are now petrol engines with fuel injection and diesel engines with spark assistance.
To add, the demarcation between the workings of petrol and diesel engines has become a bit blurred in recent times, since there are now petrol engines with fuel injection and diesel engines with spark assistance.