Today's flag of Hungary stems from the national freedom movement before 1848 which climaxed in the Hungarian Revolution of 1848, which was not only a revolution against the monarchy and to constitute a republic, but also a national movement against the Habsburgs. Thus, the tricolour feature of the flag is based on the French flag and the ideas of French revolution, while the colours red, white and green were taken from the historical coat of arms.
source: wikipedia