The heart like every other organ undergoes an intricate development during the nine months of pregnancy. The following is a basic overview of what happens to the heart as it goes from a few cells to a full scale organ.
At the end of the third week of embryonic development the primitive heart tube is formed (just a cylindrical structure). Migrating cells then invade the tube, proliferate and form an inner muscle layer: the myocardium. The heart tube starts beating on day 22, forcing blood through the embryo. During the fourth week the heart tube elongates and simultaneously loops. Such looping or folding is needed to bring prospective chambers into their correct positions relative to each other. The folding of the heart tube is completed by day 28. During the following month the walls (called septa, plural for septum) which separate the left and right atria and left and right ventricles are formed and the valves are developed.