Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Kindle Formats

Notices

Reply
 
Thread Tools Search this Thread
Old 06-23-2013, 12:38 AM   #1
santosha
Novice
santosha began at the beginning.
 
santosha's Avatar
 
Posts: 14
Karma: 10
Join Date: Jun 2013
Device: Kindle Paperwhite
Will my anchors lead astray?

I have styled my chapter headings with a paragraph class containing the styling element page-break-before: always;.

According to Amazon's guidelines I should add my anchor tags (<a name="*"/>) before my paragraph tags.

Code:
"3.10.2 HTML Guideline #2: Anchors Must Be Added Before Formatting Tags"
If I do this, is there a risk that my anchors would lead to the wrong place, since they are effectively before a page-break, through the CSS styling of the paragraph class?

For example, could a ToC item linked to this anchor end up directing someone to a blank page or even the page before the chapter heading? The intention is of course that the anchor should lead to the chapter heading.

If this would be a problem, I guess I could use the <mbp:pagebreak/> tag - but I had understood the CSS method to be more practical and also best practice. I could be wrong about that, though.

Thanks in advance!

Namaste,

Santosha
santosha is offline   Reply With Quote
Old 06-23-2013, 02:54 AM   #2
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
IMHO, it's a bad idea to use paragraph tags for chapter headings. Use heading tags (h1...h6) with ids instead. For example:

Code:
<h1 id="c1">Chapter 1</h1>
This is equivalent to:

Code:
<a name="c1"></a><h1>Chapter 1</h1>
You may want to check out Sigil. Even though it's a ePub editor you can use it to create .mobis too, because both KindleGen and Calibre will accept epubs as source files. You can also automatically generate NCX and HTML TOCs with it if you use heading tags.
Doitsu is offline   Reply With Quote
Advert
Old 06-23-2013, 06:55 AM   #3
Notjohn
mostly an observer
Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.
 
Posts: 1,515
Karma: 987654
Join Date: Dec 2012
Device: Kindle
Quote:
Originally Posted by santosha View Post
According to Amazon's guidelines I should add my anchor tags (<a name="*"/>) before my paragraph tags.
Do the guidelines actually use a name? Whenever I import my old web pages into Sigil, I get an error with that usage. Evidently we are now supposed to say id=, as Doitsu suggests. (And it is much cleaner!)
Notjohn is offline   Reply With Quote
Old 06-23-2013, 07:26 AM   #4
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,514
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
"name" is deprecated in favour of "id" in XHTML, which is what ePub is based on. But mobi uses some old pseudo-HTML code, where "name" is perfectly valid.

Sigil is an ePub authoring tool
Amazon uses mobi

that's the difference.
Jellby is offline   Reply With Quote
Old 06-23-2013, 07:58 AM   #5
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,468
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Even if you use "id" in place of "name," it's best to put those anchors before the header or other element you're linking to, like the guidelines say.

Of course the best way to avoid the styling "quirks" that can occur with MOBIs when linking to your various chapters is to not use url fragments at all. Instead, break your chapters into individual html files and link directly to the files (with no fragment). That way you don't have to worry about the "quirk" (and you won't need to use "page-break-before: always;").

Footnotes can still be problematic, but as long as you follow the guidelines and put the <a id="foo" /> anchor before your styled "target," you'll be alright.
DiapDealer is offline   Reply With Quote
Advert
Old 06-23-2013, 03:05 PM   #6
santosha
Novice
santosha began at the beginning.
 
santosha's Avatar
 
Posts: 14
Karma: 10
Join Date: Jun 2013
Device: Kindle Paperwhite
Quote:
Originally Posted by Doitsu View Post
IMHO, it's a bad idea to use paragraph tags for chapter headings. Use heading tags (h1...h6) with ids instead. For example:

Code:
<h1 id="c1">Chapter 1</h1>
This is equivalent to:

Code:
<a name="c1"></a><h1>Chapter 1</h1>
You may want to check out Sigil. Even though it's a ePub editor you can use it to create .mobis too, because both KindleGen and Calibre will accept epubs as source files. You can also automatically generate NCX and HTML TOCs with it if you use heading tags.
Many thanks Doitsu!

I will check out Sigil and give it a whirl.

I was under the impression that heading (<hn>) tags were more difficult to style, since they already have some embedded styling and any additional styling given to them via CSS might create conflicts due to the way e-readers handle headings. Is this incorrect?

Can I for example use <hn> tags to style Part- and chapter headings, and then also add elements such as text-indent:0em;, italics, and so on? Do heading tags style with relative sizes (ems)? That was the beauty I was happy to have found with styling headings with p class tags, since I could use relative units to make sure they always remained in correct relativity.

Thanks so much for all the help on the basics, it's really appreciated!
santosha is offline   Reply With Quote
Old 06-23-2013, 03:07 PM   #7
santosha
Novice
santosha began at the beginning.
 
santosha's Avatar
 
Posts: 14
Karma: 10
Join Date: Jun 2013
Device: Kindle Paperwhite
Quote:
Originally Posted by Jellby View Post
"name" is deprecated in favour of "id" in XHTML, which is what ePub is based on. But mobi uses some old pseudo-HTML code, where "name" is perfectly valid.

Sigil is an ePub authoring tool
Amazon uses mobi

that's the difference.
Thanks Jellby, I wasn't able to figure out the difference between name and id - whew!

So id works with both epub/mobi/KF8 then?

P.S. Happy "Midsommar", if you celebrate it! D.S.
santosha is offline   Reply With Quote
Old 06-23-2013, 03:15 PM   #8
santosha
Novice
santosha began at the beginning.
 
santosha's Avatar
 
Posts: 14
Karma: 10
Join Date: Jun 2013
Device: Kindle Paperwhite
Quote:
Originally Posted by DiapDealer View Post
Even if you use "id" in place of "name," it's best to put those anchors before the header or other element you're linking to, like the guidelines say.

Of course the best way to avoid the styling "quirks" that can occur with MOBIs when linking to your various chapters is to not use url fragments at all. Instead, break your chapters into individual html files and link directly to the files (with no fragment). That way you don't have to worry about the "quirk" (and you won't need to use "page-break-before: always;").

Footnotes can still be problematic, but as long as you follow the guidelines and put the <a id="foo" /> anchor before your styled "target," you'll be alright.
Thank you, DiapDealer!

I really like the idea of separating everything into different HTML files (for many reasons, clarity of overview and workflow being two of them) -- and will look more into it. I'm a little confused as to how to tell the compiler (e.g. KindleGen) actually pieces together the file in such a case, and how ToC links remain intact etc., do you have any suggestions where I could read up on this method of breaking it all up?

Is it the manifest or spine in the OPF that make sure they're placed in the right order?

When you say URL fragment, do you mean the way anchors link to chapters by referencing within a document, i.e. with #chapter1 referencing the id="chapter" element or am I misunderstanding?

Oh, and DiapDealer -- If I compile my ebook file with different files for different chapters in this way, do they automatically receive a page-break between them? I'm sort of implying from what you're saying in your post about not having to use the page-break-before:always;, but don't really understand how you mean.

Last edited by santosha; 06-23-2013 at 03:18 PM. Reason: Added question
santosha is offline   Reply With Quote
Old 06-23-2013, 04:00 PM   #9
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,582
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by santosha View Post
I was under the impression that heading (<hn>) tags were more difficult to style ...
Can I for example use <hn> tags to style Part- and chapter headings, and then also add elements such as text-indent:0em;, italics, and so on?
Headings are by default larger than body text, but can otherwise be styled exactly like all other (X)HTML elements. You should be able to recycle your paragraph styles.

BTW, Sigil uses the title attribute for all auto-generated TOCs. This'll allow you to automatically generate TOC entries that differ from the actual heading text. For example:

Code:
<h1 id="c1" title="1">Chapter 1<br />The Beginning</h1>
The above code'll display Chapter 1 followed by a line-break and The Beginning. However, if you generate a TOC with Sigil, only the chapter number will be added to the TOC.
Doitsu is offline   Reply With Quote
Old 06-23-2013, 06:28 PM   #10
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,468
Karma: 192992430
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by santosha View Post
Is it the manifest or spine in the OPF that make sure they're placed in the right order?
Spine.

Quote:
Originally Posted by santosha View Post
When you say URL fragment, do you mean the way anchors link to chapters by referencing within a document, i.e. with #chapter1 referencing the id="chapter" element or am I misunderstanding?
You're not misunderstanding. That's exactly right.

Quote:
Originally Posted by santosha View Post
Oh, and DiapDealer -- If I compile my ebook file with different files for different chapters in this way, do they automatically receive a page-break between them? I'm sort of implying from what you're saying in your post about not having to use the page-break-before:always;, but don't really understand how you mean.
Yes, there will be a page break between chapter files when compiled with Kindlegen/Previewer.
DiapDealer is offline   Reply With Quote
Old 06-24-2013, 05:01 PM   #11
Notjohn
mostly an observer
Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.
 
Posts: 1,515
Karma: 987654
Join Date: Dec 2012
Device: Kindle
Quote:
Originally Posted by santosha View Post
So id works with both epub/mobi/KF8 then?

P.S. Happy "Midsommar", if you celebrate it! D.S.
Yes, it does. (Actually, I upload the epub file to the KDP, where it converts nicely.)

We don't exactly celebrate Midsommer, but we do take note of it, though we think of it more awkwardly as Longest Day Of The Year....
Notjohn is offline   Reply With Quote
Old 06-25-2013, 05:31 AM   #12
Hitch
Bookmaker & Cat Slave
Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.Hitch ought to be getting tired of karma fortunes by now.
 
Hitch's Avatar
 
Posts: 11,448
Karma: 157030631
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
Quote:
Originally Posted by Notjohn View Post
Yes, it does. (Actually, I upload the epub file to the KDP, where it converts nicely.)

We don't exactly celebrate Midsommer, but we do take note of it, though we think of it more awkwardly as Longest Day Of The Year....
Solstice, nj, Solstice. ;-)

Hitch
Hitch is offline   Reply With Quote
Old 06-28-2013, 10:45 PM   #13
santosha
Novice
santosha began at the beginning.
 
santosha's Avatar
 
Posts: 14
Karma: 10
Join Date: Jun 2013
Device: Kindle Paperwhite
Thanks a lot for you guys' help Doitsu, NJ and Diap!
santosha is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Anchors in posts? unboggling Feedback 16 05-17-2015 03:18 PM
Links and anchors dicknskip Sigil 6 04-11-2013 11:43 PM
Links and anchors question holdit ePub 10 02-15-2013 03:28 PM
Anchors look like links in ADE? BKh Workshop 8 01-29-2012 03:19 PM
Help With Capital Letter Going Astray Marcy Calibre 3 08-10-2010 11:38 AM


All times are GMT -4. The time now is 09:43 PM.


MobileRead.com is a privately owned, operated and funded community.