In fiction, canon is the material accepted as officially part of the story in an individual universe of that story. It is often contrasted with, or used as the basis for, works of fan fiction. The alternative terms mythology, timeline, and continuity are often used, with the former being especially to refer to a richly detailed fictional canon requiring a large degree of suspension of disbelief (e.g. an entire imaginary world and history), while the latter two typically refer to a single arc where all events are directly connected chronologically. Other times, the word can mean "to be acknowledged by the creator(s)."
The use of the word "canon" in reference to a set of texts derives from Biblical canon, the set of books regarded as scripture, as contrasted with non-canonical Apocrypha. The term was first used by analogy in the context of fiction to refer to the Sherlock Holmes stories and novels, written by Sir Arthur Conan Doyle. Ronald Knox used the term in a 1911 essay "Studies in the Literature of Sherlock Holmes" to distinguish Doyle's works from subsequent pastiches by other authors. It has subsequently been applied to many media franchises. Among these are science fiction and fantasy franchises such as Star Trek, Star Wars, Harry Potter, Halo, Fallout, The Elder Scrolls, Mass Effect, BioShock, Doctor Who, Middle-earth, A Song of Ice and Fire, the Narnia series, the The Dark Tower books, and Dinotopia, in which many stories have been told in different media, some of which may contradict or appear to contradict each other.
When there are multiple "official" works or original media, the question of what is and what is not canonical can be unclear. This is resolved either by explicitly excluding certain media from the status of canon (as in the case of Star Trek and Star Wars), by assigning different levels of canonicity to different media (as was in the case of Star Wars before the franchise was purchased by Disney), by considering different but licensed media treatments official and equally canonical to the series timeline within their own continuities universe, but not across them (as with Battlestar Galactica, Sonic X, Fullmetal Alchemist, Teen Titans, The Walking Dead TV show, Kirby Right back at Ya!, The Resident Evil movies, Silent Hill: Shattered Memories), or not resolved at all. The use of canon is of particular importance with regard to reboots or re-imaginings of established franchises, such as the 2009 Star Trek film, because of the ways in which it influences the viewer experience.
The official Star Trek website describes Star Trek canon as "the events that take place within the episodes and movies" (that is, the television series Star Trek: The Original Series, Star Trek: The Next Generation, Star Trek: Deep Space Nine, Star Trek: Voyager, Star Trek: Enterprise, and the Star Trek motion pictures). Events, characters and story lines from tie-in novels, comic books, and video games are explicitly excluded from the Star Trek canon, but the site notes that elements from these sources have been subsequently introduced into the television series, and says that "canon is not something set in stone." One example of a non-canonical element that later became canonical in the Star Trek universe was the name "Tiberius" becoming the official middle name of Enterprise captain James T. Kirk. The name was introduced in the Star Trek animated series, and was later added into the official biography of the character by its mention in the live-action film Star Trek VI: The Undiscovered Country.
The Star Wars canon originally existed on several levels. The highest level was the original Star Wars films, and statements by George Lucas; tie-in fiction from the Star Wars expanded universe had a different level of canonicity. The complex system was maintained by Leland Chee, a Lucasfilm employee. After Disney bought the franchise, all material published prior to April 25, 2014 that was not any of the Star Wars movies or the CGI cartoon The Clone Wars was declared in the "Legends" continuity, marking them as no longer official canon. All subsequent material exists on the same level of canon, with the Lucasfilm Story Group being established to ensure no contradictions among canon works.
The makers of Doctor Who have generally avoided making pronouncements about canonicity, with Russell T Davies explaining that he does not think about the concept for the Doctor Who TV series or its spin-offs.
Fan fiction is almost never regarded as canonical. However, certain ideas may become influential or widely accepted within fan communities, who refer to such ideas as "fanon", a portmanteau of fan and canon.
Fanon is a common feature in large franchises and fictional universes where there are many canon and non-canon works, as in the Star Trek universe.