First, I'm not an expert on Calibre, although I do know a lot about how to use it. Nor am I an expert on CSS stylesheets although I can get some simple ones to work. Nor am I an expert on E-pub files, but I do create a lot and they validate properly.
Until recently I created my e-pub files by importing the .odt file into Calibre and then using that to create the e-pub file. To help with this I use paragraph styles within the .odt file. I recently had someone tell me that the e-pub files I was creating were exceptionally large for the size of the document within them. I investigated and found out that the way i had the system set up it was embedding the fonts into the files. I stopped that and it cut the file a lot, but it still seemed high according to the reader checking them for me - hey he started it, he can check 'em.
I next used the Edit function within Calibre to look at the e-pub file and found that where I had 17 paragraph styles in Libre Office and 7 of those were deleted prior to making the e-pub (it doesn't need the footers, headers, of contents styles) Calibre was creating about 40 paragraph styles to use within the CSS stylesheet for the e-pub from the 10 paragraph styles I had in the text file. Thus I went to look at ways to make the file smaller.
For a long time another author has been telling me to use CSS stylesheets, something I'd not used before, so I started using simple ones based on the ones used on SoL - Yes, CW, I do listen to you at times.
Anyway, I attempted a more complex CSS stylesheet and revised my Libre Office paragraph styles to better suit the CSS stylesheet codes I set up with all the paragraph format code except the font name - thus it had the font size, font color, if it was bold etc, spacing info etc. I ended up with 10 sets of data to cover all of the paragraph styles I use. I then used this to create the HTML variant of the story (something I do anyway) and then imported the HTML file into Calibre to create the e-pub. The result was a much smaller e-pub file, but it would not validate and it kept telling me each of the splits in the e-pub had faulty file names.
I've spent five days playing with things to see if I could get it to work because it should. I finally got everything to work and have Calibre create valid e-pub files from the HTML code with the CSS stylesheet. The fix was simple in the end.
When I add a word processing file to the Calibre library it adds my name to the file before it saves it. Thus the file Play Ball!.odt becomes Play Ball!- Ernest Bywater.odt. However, when I import the HTML file the file Play Ball!.html becomes Play Ball! - Ernest Bywater.zip. in both cases the finished e-pub is Play Ball! - Ernest Bywater.epub - but the one from the HTML fails validation due to the file name failure.
On examining both files in the Calibre Edit system I noticed a difference in the names for the sub-files. At each page break in the initial file the e-pub makes a split and creates it as another sub-file. The files start at number 000 and increase as the extra breaks are added. The sub-files from the .odt file were all named index_split_000.xhtml while the ones from the HTML were named Play Ball!_split_000.xhtml. While looking at them I remembered the old FAT16 file naming convention and tried that.
I went back to the HTML file and changed its name from Play Ball!.html to Play_Ball!.html and created the e-pub file which came out as the same name as before. However, the file validated and a check inside showed the sub files as Play_Ball_split_000.xhtml.
In short, if you want to create an e-pub from your HTML file using Calibre you need to make sure there are no blank space in the file name before you take it into Calibre, simply replace them with the underscore character of _ and the system will work for you. It will have a file name failure if you leave a blank space in it.
I've no idea why Calibre plays nice with the Word Processor files and not the HTML files, but that's the way it is.