Electronic books can be available in a number of formats. The most obvious one is plain text. Such files usually have the .txt filename extension and can be opened on any computer running any operating system, as plain text is the most widely supported format. Project Gutenberg has most of its free ebook library as plain text TXT files.
TXT e-books are great in the sense that every system supports them without any additional tools. But there are some problems. Such plain text files have very limited formatting capabilities. For example, you cannot have bold or italic in text files, just lowercase and uppercase letters. Indentation and new lines are pretty much fixed. You can use colors and fonts to mark out certain items. No images can be included into the text. The text does not flow to fill out the available screen area. There is no interactive table of contents.
Somewhat similar to TXT e-books, there are such formats as DOC, DOCX, RTF, HTML. They are "general purpose" formats: DOC, DOCX, and RTF are so called "rich-text" formats that allow saving such information as fonts, colors, font sizes, indentation, and many other details. You can even have pictures in such files. HTML is the format used everywhere on the internet, so it allows doing all the things, too. Normally e-books in these formats look great, but the formats are poorly supported by various reader programs and devices. If you have an e-book in DOC, RTF, HTML, or DOCX, you will find out that the e-book can be converted to a format supported by your reader, but most magic will be gone. This happens due to the fact that these files do not have any clear e-book oriented structure. The e-book converter program may fail to recognize where the title and where the author's name are, will dismiss any internal links, etc.
Further, there are such formats as PDF. Specially designed to contain electronic documents of all sorts, they offer a great set of features. An ebook in the PDF format may look as great as any paper book. PDF files can include a table of contents with clickable entries, footnotes and endnotes, pictures, various fonts, and much more. The PDF format is decently supported by various e-reader devices, but there are two problems: such files have a fixed page size and they cannot be converted to a different format with all the formatting and features. The first problem may result into your e-reader showing too small characters, making the text unreadable, and the second problem will prevent you from fixing the first one. While e-book reader devices may re-format PDF text according to the selected font size, in most cases the result does not look as nice as the original document.
Finally, there are special formats for e-books, like EPUB, MOBI, AZW, PRC, FB2. They offer rich sets of features, including text formatting, fonts, footnotes and endnotes, special fields for authors and titles, and so on. Some of them may also include a digital rights management system (DRM) with the purpose of preventing illegal copying of the copyrighted content. Every e-book reader device has its own preferred format, for Amazon Kindle it's AZW, MOBI, PRC (they all are variants of the same format), for Barnes & Noble's Nook, Sony Reader and many others it's EPUB. E-books in these formats can be easily sorted by author, title, genre, series, which is not possible with other formats. This makes them the best choice for a home e-library.