Why is there foam inside the dehumidifier tank?

The foam is used to determine the water level in your dehumidifier tank to ensure the unit doesn’t overflow.