04-15-2012, 03:07 PM | #1 |
Evangelist
Posts: 480
Karma: 270594
Join Date: Aug 2010
Device: palm tx, Windows7, Galaxy A5
|
Mysterious html
Hi,
I apologize if it's wrong place to put my question. I decided to tweak some mobi books but my knowledge of html is sadly lacking. Could somebody please enlighten me: <p height="0em" width="0pt"> why not simple </br> ? or <a></a> - why? An empty anchor? <a></a><p height="1em" width="5em"> seems to be put randomly before paragraph tags. I know what happens when I change p-s to <p height="0em" width="2em">, but that's all. Can I delete all <a></a>-s? Can I replace <p height...> tag to simple <p> (I think Mobi Creator takes care of indents)? (Well, I know that I can, but does it affect future conversion or readability in other readers etc?) Most important, WHY <p height...> if <p> or </br> is sufficient? Thank you. |
04-15-2012, 03:42 PM | #2 |
eBook Enthusiast
Posts: 85,544
Karma: 93383043
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
The "width=" and "height=" attribute on a paragraph in a Mobi book are used to control the indent of the first line, and the space between paragraphs, respectively.
|
04-15-2012, 04:15 PM | #3 |
Evangelist
Posts: 480
Karma: 270594
Join Date: Aug 2010
Device: palm tx, Windows7, Galaxy A5
|
Yes, that's almost only thing here I understand. So if I don't want any space between the paragraphs, I can delete whole height 1em part? And then search and replace bigger ems with br/?
|
04-15-2012, 04:36 PM | #4 | |
Grand Sorcerer
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
And <br /> will only ever get you to the next line. You can't "stack" them to make a larger space. |
|
04-15-2012, 04:43 PM | #5 |
Wizzard
Posts: 11,517
Karma: 33048258
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International, Sony PRS-T1, BlackBerry PlayBook, Acer Iconia
|
Actually, when run through KindleGen, at least, a bare <p> with no height or width set will give indented paragraphs with no space between them, at least in results viewed on a K2. It might be different for KF8 format output.
If you want no-indent and linespacing, then you have to set height/width wherever you want it in the <p>s or via CSS before conversion. |
04-15-2012, 04:48 PM | #6 |
Grand Sorcerer
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I stand corrected. I knew I should have done some testing.
|
04-15-2012, 05:23 PM | #7 |
Evangelist
Posts: 480
Karma: 270594
Join Date: Aug 2010
Device: palm tx, Windows7, Galaxy A5
|
That's my point: maybe there's some good reason why book has to be cluttered with so much code, if so, I'd like to know. Or is it all just junk from word conversion?
Why not use <br> instead of <p height="0em" width="0pt"> ? Both result in one empty row, yes? But if I want to convert to ePub, could it be that it likes attributed variant more than <br/>? And I have a feeling that I can stack <br>-s to make larger space. I won't see bigger space if I open html in the browser, only after putting it through MobiCreator. |
04-15-2012, 05:33 PM | #8 |
Wizzard
Posts: 11,517
Karma: 33048258
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International, Sony PRS-T1, BlackBerry PlayBook, Acer Iconia
|
Much, but not all, of what shows up in an unpacked Mobi file is often redundant or inapplicable carryover cruft (like font-face changes which involve named fonts which are not carried in any of the Kindle devices or apps).
You can safely strip out all the non-functional stuff and replace most of the hard-coded functional bits with some CSS classes and a stylesheet whether you recompile as Mobi or go on to convert to ePub. The best way to figure out (besides trial and error experimentation) is by referring to the official Mobipocket format documentation, such as it is, for which bits are actually functional and non-redundant to the display defaults. ETA: Amazon's Kindle Publishing Guidelines PDF may also be of use. IIRC they used to have some kind of appendix of CSS tags in the back which could get "translated" to the Mobi format version of HTML. Last edited by ATDrake; 04-15-2012 at 05:38 PM. |
04-15-2012, 05:40 PM | #9 | |
Grand Sorcerer
Posts: 27,548
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
|
|
04-15-2012, 05:57 PM | #10 |
Evangelist
Posts: 480
Karma: 270594
Join Date: Aug 2010
Device: palm tx, Windows7, Galaxy A5
|
I have frowned over official documentation, but it's rather poor on 'why' part. 'This is useless crap' and 'this works nicely' I can usually find with experimentation, but WHY...
I am under impression that mobi does not support CSS? That it embeds Css things into html when building mobi? |
04-15-2012, 06:30 PM | #11 |
Wizzard
Posts: 11,517
Karma: 33048258
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International, Sony PRS-T1, BlackBerry PlayBook, Acer Iconia
|
That's exactly right. CSS is just used for your preparatory convenience. It all gets reinterpreted into the corresponding HTML when the Mobi is actually made.
The Mobipocket documentation's most useful applicable part is probably the list of supported HTML tags, which at least gives you an idea of what a given tag will do and how it ends up displaying, and what options you have for modifying the display (not many). At least you get a sense of what won't work, keeping in mind that Mobi is really based on some kind of modified version of the old HTML 3.2, IIRC. |
04-15-2012, 07:30 PM | #12 |
Fledgling Demagogue
Posts: 2,384
Karma: 31132263
Join Date: Feb 2011
Location: White Plains
Device: Clara HD; Oasis 2; Aura HD; iPad Air; PRS-350; Galaxy S7.
|
Does MR have a reference library section for the creation of e-reader content? If not, it should. We should collaborate on or link to a guide to creating bulletproof e-books in various formats, a glossary of code for someone who's never learned HTML, and still another on cleaning up preexisting e-books.
|
04-16-2012, 01:03 AM | #13 |
Evangelist
Posts: 480
Karma: 270594
Join Date: Aug 2010
Device: palm tx, Windows7, Galaxy A5
|
Thank you for your help.
Some kind of simplified guide is excellent idea. There are lots of good 'html for beginners' tutorials, but they all tend to stray into webpage building and that's much too complicated for (my) ebook needs. Example from toc: <div height="0em"></div><a filepos="0000067426"><span><span>Chapter 3</span></span></a><br/> 1. WHY 2x span? 2.The <div> tag is used to group block-elements to format them with styles - but lots of styles in ebook are not such a good idea? (different readers etc). I imagine vaguely how I may want to color some block pink or green... Does mobi ebook need <div> tag at all? In that example <div> says only that there's no empty space between lines in toc, so why not: <p height="0em" width="0em"> ? or: <a filepos="0000067426">Chapter 3</a><br/> ? Another example: <a></a><p width="-58pt" align="left"><a href="#filepos50598"><font color="blue"><u>Chapter 1</u></font></a></p> WHY <a> without any attribute? I've understood one-letter tags like <a> and <b>, but <div> and <span> confuse me to tears. |
04-16-2012, 01:23 AM | #14 |
eBook Enthusiast
Posts: 85,544
Karma: 93383043
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
It's probably machine-generated code. I wouldn't lose any sleep over it.
|
04-16-2012, 01:24 AM | #15 |
Wizzard
Posts: 11,517
Karma: 33048258
Join Date: Mar 2010
Location: Roundworld
Device: Kindle 2 International, Sony PRS-T1, BlackBerry PlayBook, Acer Iconia
|
1. The span is total cruft, probably left behind by some messy word processor auto-html. Feel free to get rid of it. Spans are only ever important in an e-book if they have a class as a hook for some sort of CSS formatting or a lang attribute to denote a foreign language phrase you might want to format differently to make it stand out.
2. That particular div looks superfluous, especially with a height of 0 em and nothing inside. If a div has nothing inside, assume it's cruft and delete. Only if it's got a height set might you possibly want to keep it in case it's some sort of important scene spacer, but you can get a much better effect by wrapping a new div around the entire "spaced" section and giving it a class hook to anchor some CSS formatting to get the linespacing effect (or just put in a manual spacer like an <hr /> line). You wouldn't need a <p> with height set to 0, because the default for Mobi display on e-ink Kindles (may be different on K4apps and other readers) is for no spacing between lines by default anyway. However, you could wrap the <a> within a <p> and omit the <br /> as you'd get a line-break with the <p> anyway and that would allow you to style the formatting later in case you decide you do want some space between lines or you want no-indent in the TOC entries (the functional part of the hypothetical <p width="0">). 3. That <a> is actually functional and pretty important, as it acts as a link to wherever Chapter 3 is located. You need to keep that one. But you can get rid of the font tags. You can't even see colours in most Mobi-supporting devices anyway (maybe K4PC/iDevice apps). All you really need to look at in an HTML tutorial is what the "presentational attributes" possible for a given HTML tag are, because that's all you'll be able to use with Mobi, and you'll only be able to use a small subset of them (eg. anything involving setting a colour, you can ignore). Hope this helps. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre Recipe HTML content differs from raw html of index.html. | krunk | Calibre | 4 | 09-20-2010 09:48 PM |
Access to local HTML files and content, HTML ebooks, annotation on HTML ebooks | leo315 | enTourage Archive | 2 | 05-10-2010 02:40 PM |
Mysterious Island | mtravellerh | Deals and Resources (No Self-Promotion or Affiliate Links) | 0 | 12-27-2008 05:28 AM |
Mysterious Companion software | sarikan | iRex | 6 | 11-27-2008 04:37 AM |
The Mysterious Island | kevinofengland | Sony Reader | 6 | 09-27-2008 08:52 AM |