There are two main parts to a fuel gauge: the sender and the gauge. The sender is a float that is in the car's gas tank. The sender tells the gauge how much fuel is left in the tank, and this information is displayed on the dash of the car.
The sending unit is a float typically made of foam that is connected to a thin, metal rod. That metal rod is then connected to a resistor. A resistor is a device that works to reduce current flow.
When the sender float is near the top of the tank, the resistance is low and so a large amount of current can flow. As the float descends in the tank as the engine uses gas, the resistance goes up and less current can make it through. The gauge has a bimetallic strip with a heater coil attached to the top. When the resistance goes up, there is less current going to the heater coil, and the bimetallic strip starts to cool and straighten out. As the strip straightens out, it pulls the fuel gauge on the dash towards empty.
In some newer cars, the fuel gauge is controlled by a microprocessor that tells the fuel gauge what the resistance currently is, and the fuel gauge responds to that amount.