I’ve heard it argued by that square waves contain DC. How else could they have the flat top and bottom that make it square?
Let’s look at a square wave and see what causes it to have its square shape.
A complex waveform can be constructed from, or decomposed into, sine (and cosine) waves of various amplitude and phase relationships.
This is the basis of Fourier analysis. A square wave consists of a fundamental sine wave (of the same frequency as the square wave) and odd harmonics of the fundamental.
The amplitude of the harmonics is equal to 1/N where N is the harmonic (1, 3, 5, 7…). Each harmonic has the same phase relationship to the fundamental.
If we construct a square wave from just the first two harmonic components we can begin to see how the square shape occurs (Figure 1).
We can see here that the red trace is the first harmonic (fundamental) and the green trace is the third harmonic at its correct amplitude.
Figure 1: Square wave generated from only two components. (click to enlarge)
When the first harmonic is at its maximum value the third harmonic is’ at its minimum value. By adding these two together we get the black trace, which is starting to resemble a square wave.
If we now use five harmonic components 0, 3, 5, 7 and 9) to construct the square wave we see it really starting to take shape (Figure 2).
Figure 2: Square wave generated from five components. (click to enlarge)
At the end of each half cycle of the square wave all of the harmonic components are all going the same direction (either positive going or negative going). This is what accounts for the sharp rise.
Towards the middle of each half cycle the harmonics alternate between being at minimum and maximum amplitude just as we saw in Figure 1. This is what accounts for the flat portion of the square wave. Increasing to 10 harmonic components results in Figure 3.
Figure 3 - Square wave generated from 10 components. (click to enlarge)
Note that only the first six harmonics are shown individually, but 10 harmonics are used to generate the square wave. Increasing still further to 100 and 1,000 harmonic components are shown in Figure 4 and Figure 5, respectively.
Figure 4 - Square wave generated from 100 components. (click to enlarge)
Figure 5 - Square wave generated from 1,000 components. (click to enlarge)
From these graphs it should be well understood that the high frequency harmonic content, and not a DC component (0 Hz), is responsible for the shape of a square wave.