Kindle Formatting: The Complete Guide To Formatting Books For The Amazon Kindle [non-affiliate Amazon link]
That also has a Kindle Formatting website.
EPUB Straight to the Point: Creating ebooks for the Apple iPad and other ereaders [non-affiliate Amazon link]
That has a background website.
When I read posts such as this — Is Amazon Too Big for Kindle? — whining about formatting problems, it tends to get up my nose.
There are books out there to Help You Do This.
These two books are by absolute experts.
Now go buy them, read them, and use them!