In the 1800s, both boys and girls wore long white dresses. Even as late as 1829, children were dressed in unisex dresses. In the 1920s, Macy's tried to distinguish a color for boys and girls to discourage hand-me-downs.
Red has always been a strong color in the Christian tradition, and associated with men. Pink became a boys' color as a lighter hue of red. Blue was associated with the Virgin Mary and therefore considered a girls' color.
After the World War I, and soldiers' uniforms made in blue, it became associated as a masculine color. After the 1940s, pink became more of a feminine color. The idea was later perpetuated by marketing groups that pushed the post-war consumer boom and the creation of the middle class in the 1950s. Barbie, introduced in 1951, solidified the feminization of the color pink.