If you're looking for the short (and somewhat inaccurate) story: The EPUB format is the industry standard, and the file is sort of like a zipped up website. The book itself is written in the same code used to write web pages, and fancier books have extra files zipped into the final package.
If you're not familiar with the idea of "zipping up" a file, just imagine it as packing up all the stuff in your room. Your unpacked room represents all the various files and formats you'd like in the finished product; the single box you end up with that contains everything from your room is the zipped-up file.
For the more involved (and more technically correct) story, a basic EPUB file consists of the following:
· A bunch of pages written in XHTML that contain the written content of the book;
· CSS (Cascading Style Sheets) to provide formatting;
· An XML file with the extension .opf that contains the book's metadata (title, the language it's written in, &c);
· An XML file with the extension .ncx that contains the book's hierarchical table of contents.
These last two XML files are what really separate an e-book from a website: they provide a linear structure to the book that require (for the most part) that it be read in a certain order. (Many books do contain hyperlinks and allow you to skip from page to page this way.)
Now, although EPUB is the standard by which the industry operates, not all e-book retailers use it (and those who do generally modify the files they receive from publishers or individuals to suit their particular standards). This is why e-books often look different from device to device.
The most visible example is that of Amazon's Kindle, which pretty much reads anything except EPUB (e.g. MOBI, PRC, AZW, PDF). Because Amazon needs to convert EPUB files before it can sell them to consumers, e-books may not always appear as publishers intended (due to the translation process in general, how the two coding systems handle different objects like tables and captions, and so on). What is possible via EPUB may not be possible in, say, MOBI, and vice-versa.
While I think that formats and devices will consolidate over time, I very much doubt we're going to see a one-format, handful-of-devices scenario for awhile. The good news is that there are ways to convert almost any file type to any other file type and many devices can either cross-read or run apps that are capable of doing so, so your library hopefully won't be (too) fragmented for the time being.
That's it for today, amigos and -as. Friday: the pre-Valentine's Day round-up!