A Horcrux is: 'the receptacle in which a Dark wizard has hidden a fragment of his soul for the purposes of attaining immortality'. (JKR) Diary entry - September 29, 2006
Horcruxes are indeed a matter involving very advanced, very Dark magic. Only one book in the Hogwarts library has been found to refer to them even in passing, the subject is banned at Hogwarts, and only two of the most senior professors on the Hogwarts staff are known to have any information on the topic: Albus Dumbledore and Horace Slughorn. Most of our information on Horcruxes comes from them, particularly from Professor Slughorn's memory of a fateful conversation with the young Tom Riddle and Professor Dumbledore's later analysis of that memory (HBP23).
The term "Horcrux" is used to refer to any object in which a person has concealed a part of his or her soul. The object need not be inanimate; according to Dumbledore, a living creature can be used as a Horcrux, although it is risky to do so since the Horcrux in such a case is something that can move and think for itself, independently of the implanted fragment of soul.
The purpose of a Horcrux is to protect the given bit of soul from anything that might happen to the body of the person to whom the soul belongs. While the Horcrux is kept safe, the person will continue to exist even if his or her body is damaged or destroyed.
To create a Horcrux, by definition the spell-caster must have split his or her soul into fragments, so that one fragment can be implanted within the Horcrux while the other is retained in the spell-caster's own body. The act of splitting the soul is accomplished by committing murder, which rips the soul apart. From Dumbledore's remarks about Voldemort's possible planned use of the murders of the Potters when Harry was a baby and of Frank Bryce's murder in 1994 [Y14], it does not matter whether the victim is a witch, wizard, or Muggle. According to Slughorn, some spell appears to be involved for the implant process, but Slughorn neither knew nor wished to know the details (HBP23).
Tom Marvolo Riddle, later known as Voldemort, became obsessed with avoiding death at a very young age. At some point during his early years at Hogwarts, despite the fact that the topic of Horcruxes was not part of the curriculum and was in fact banned at the school, Riddle learned of their existence.
Riddle hit upon the idea of creating not just one Horcrux to protect part of his soul, but several at once: a grand total of six Horcruxes, so that he would eventually have a seven-part soul, with six parts concealed in various Horcruxes and the seventh remaining in his body. Under a pretense of academic curiosity, he sought Horace Slughorn's opinion as to whether this would be an effective procedure, and apparently was satisfied with the answer he got (HBP23). It is worth noting that since Riddle was already in possession of his maternal grandfather's ring at the time of his conversation with Slughorn, he had at that point already committed at least three murders (those of his paternal grandparents and his father) and had framed his maternal uncle for the crimes.
Known and Candidate Horcruxes
According to Albus Dumbledore's analysis of Riddle's character, which seems to be borne out by the known facts, Riddle is likely to choose as Horcruxes objects of some significance to him, which he deems worthy of protecting bits of his soul. Artifacts from each of the four Founders of Hogwarts, it is suspected, would particularly appeal to him.
Apart from these two categories, there are other possibilities for the last two unaccounted-for Horcruxes.
Apart from the issue of what objects might be Horcruxes, we also come to the question of where the remaining Horcruxes might be hidden, if they are inanimate objects. Judging from what is known of the Horcruxes accounted for so far, the most likely hiding places would be places significant to Riddle thanks to some personal association. The most likely places would appear to be the Muggle orphanage where Riddle was born and grew up, Hogwarts itself (particularly the Chamber of Secrets, if Riddle was able to gain access at some time during the years after Myrtle's death), and the Riddle House.