As Richard stated already, each army had its own mode of doing battle honors - some armies had several methods within that army!
The Army of Northern Virginia began with battle honors for "Seven Pines" and "Williamsburg" in the Summer of 1862 by general order. These were block painted in black letters on white cotton strips that were then sewn to the flags typically with the older battle in the upper quadrant and the more recent in the lower.
After the Maryland Campaign, some of Lee's brigades took it upon themselves to have their flags decorated with honors. These brigades include Lane's NC Brigade, Kershaw's SC Brigade and McGowan's SC Brigade (the same artist did these) which were done in white painted letters of a fancy style. The Florida Brigade also see,ed to go with honors on strips sewn to the flags.
Other brigades went only with unit designations but most ANV flags were not marked at all.
In 1863 divisional issues began. In April, the units of D.H. Hill's Division (later Pender's) received new flags with dark blue painted honors with the last honor being for "Fredericksburg." These were done in chronological order with the older battles in the upper quadrant; the next oldest in the left quadrant; the next oldest in the right quadrant and the most recent in the bottom quadrant.
After Chancellorsville in May, A. P. Hill's Light Division received new flags with honors in the same style with the last battle honor being for "Chancellorsville." This division was six brigades at this time and in the reorganization of the divisions to four brigades in June, two brigades formed part of Harry Heth's new division.
In June, Pickett's Division received new flags with their unit designations painted across the field in white paint. Ed Johnson's Division was supposed to get new flags before the Gettysburg Campaign but a bunting shortage at the Richmond Depot postponed this until September when a new shipment arrived (in August) via blockade runner.
In September, Johnson's Division finally got their new flags and these had as their current honors "Gettysburg." Also receiving flags with this honor were those units of Heth's Division that lost flags in that battle.
From here the issue of these honors fell back to the brigades. Cox's NC Brigade got new flags with honors in eitehr late 1863 or early 1864, for example. The artist that did these dark blue painted honors was Lewis Montague of Richmond, VA.
In the West, general orders also established battle honors for units with the first two being for "Shiloh" and then "Perryville." More honors would come later but like in the ANV not all flags were so decorated or marked with unit names.
Unique honors for the West were the crossed cannon honors which were earned only after capturing a Union artillery battle that was shooting at the atatcking unit. These were very well earned honors indeed!
If you look in the "Arms & Equipment of the Confederacy" book by Time-Life, you will see CS flags marked as I have described above.
Battle honors date back to the Roman legions who woul;d decorate their vexillum and standards with signs of the zodiac, etc. and even some of the places where they fought. In the musket era honors came from the British and Napoleonic French.