The National Archives provides online records for veterans, their families, and researchers looking into the history of men and women who have served in the US military during wartime, from the American Revolution to the present. (Additional records and resources are available in print -- see here for more details.)
Below is a sample of what the National Archives offers -- see the Online Veterans and Military Service page for more.
Civil War
Spanish-American War
World War II
Korean War
Vietnam War