To avoid colliding with the car in front of you, you should:

To avoid rear-end collisions, it is helpful to look for break lights and other hazards in the traffic ahead of your vehicle. It is recommended that you maintain a following distance of four seconds when driving under ideal conditions.
DMV Writen Test