![]() |
#1 |
Connoisseur
![]() Posts: 60
Karma: 10
Join Date: Mar 2011
Location: UK
Device: Kindle 3, iPhone, iPad, PC
|
ePub validation error - not liking div tags
Hi all, I hope you can help.
I've used Indesign CS5.5 to create an epub with pictures inside. I unzipped the epub for basic editing. I don't know html but there are a couple of things I've picked up from the internet to improve the look of my book (and fix incorrect fonts). I added some div.groups for images in the CSS file which has image sizing instructions. And in many of the html files I have taken out the image code and replaced it with this Code:
<div class="group1"> <img src="exampleimage" alt="example" /> </div> I tested it with EPub validator and it has over 300 errors of the same type. It list the html file and then element "div" from namespace "http://www.w3.org/1999/xhtml" not allowed in this context The strange thing is I have created two other books in this way and they were fine and have been published. If it was one or two errors I would suspect I had messed up the html code, but because it is around 300 errors I suspect something different. A common element of the line just before the div lines listed above is this. Code:
<p class="body"><span class="body" style="font-size:0.86em;"><br/> |
![]() |
![]() |
![]() |
#2 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,341
Karma: 203719646
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
EDIT: I may be wrong about that. I'm not entirely sure. Last edited by DiapDealer; 07-18-2012 at 02:54 PM. |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 78,991
Karma: 144284074
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
You cannot put a <div> inside a <p>. That's not valid code. And also, the code you have is just really poor code.
Code:
<p class="group1"><img src="exampleimage" alt="example" /></p> |
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,341
Karma: 203719646
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
If we're talking about html, I'd whole-heartedly agree. But I'm just not certain that's gospel when it comes to xhtml (even though I had the same initial response as you did). I don't see any real good reason to do it, but I'm not so sure it's technically against xhtml rules. The W3C xhtml validator didn't barf on a <div> inside a <span> inside a <p> when I tried it. Does ePub specifically prohibit it? *shrugs*
Last edited by DiapDealer; 07-18-2012 at 07:43 PM. |
![]() |
![]() |
![]() |
#5 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 78,991
Karma: 144284074
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,341
Karma: 203719646
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
|
|
![]() |
![]() |
![]() |
#7 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
I've always found it difficult to get things clear with XHTML, the specs are not written for humans and all together...
However, it says here (msg 3090864) that XHTML does not allow block-level content inside <p> tags either. Diving into XHTML 1.1, I reached this. Note it says: Code:
<xs:group name="xhtml.p.content"> <xs:sequence> <xs:group ref="xhtml.Inline.mix" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:group> |
![]() |
![]() |
![]() |
#8 |
Connoisseur
![]() Posts: 60
Karma: 10
Join Date: Mar 2011
Location: UK
Device: Kindle 3, iPhone, iPad, PC
|
Thanks for your input so far.
I've been trying to compare with the code of another book. This is the code of an old book that validates: Code:
<span class="body" style="font-size:0.86em;"> my text</span></p> <p class="body"><span class="body" style="font-size:0.86em;"></span></p> <div class="group1"> <img src="images/S57_fmt.jpeg" alt="alt text" /> </div> <p class="body"><span class="body" style="font-size:0.86em;">my text</span> Code:
<span class="body" style="font-size:0.86em;"> my text</span></p> <p class="body"><span class="body" style="font-size:0.86em;"><br/> <div class="group1"> <img src="images/E7-10_fmt.jpeg" alt="alt text" /> </div> <br/>my text</span></p> What Im thinking is that I have to put a </span> at the end of the first line. And then put the character style line at the front of the last line to make it valid? |
![]() |
![]() |
![]() |
#9 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
You have to put the <div> outside the <p>, so you have to close the <p> and the <span> before the <div>, and open them again after the </div> (and get rid of the <br/>'s):
Code:
<span class="body" style="font-size:0.86em;"> my text</span></p> <p class="body"><span class="body" style="font-size:0.86em;"></span></p> <div class="group1"> <img src="images/E7-10_fmt.jpeg" alt="alt text" /> </div> <p class="body"><span class="body" style="font-size:0.86em;">my text</span></p> |
![]() |
![]() |
![]() |
#10 |
Connoisseur
![]() Posts: 60
Karma: 10
Join Date: Mar 2011
Location: UK
Device: Kindle 3, iPhone, iPad, PC
|
Thank you Jellby! Im going to try that on a few pages now.
But if I need to put in the page break </p> just before or after the image (to make the page look prettier) where is okay to put it? |
![]() |
![]() |
![]() |
#11 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
You could try to use more CSS classes to make it better readable. I would put the font-size in the stylesheet for sure.
Are you saying that your second example with the <div> inside the <p> tags validates in Sigil? That would surprise me actually. |
![]() |
![]() |
![]() |
#12 | ||
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,341
Karma: 203719646
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
Neither does W3C's validator. I was rather shocked that neither flagged it as problematic, truth be told. Quote:
![]() Last edited by DiapDealer; 07-19-2012 at 07:40 AM. |
||
![]() |
![]() |
![]() |
#13 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Indeed. At least the W3C validator should react to it...
|
![]() |
![]() |
![]() |
#14 | |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,543
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
It must be something else, maybe the headers. I get a validation error in W3C with this file:
Code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ops="http://www.idpf.org/2007/ops" xml:lang="en"> <head> <title>Title</title> </head> <body> <p>Test <div>inner div</div> </p> </body> </html> Quote:
|
|
![]() |
![]() |
![]() |
#15 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,341
Karma: 203719646
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
![]() So given that ... it's quite clear why Kratos' first example might validate (assuming the snippet had proper opening/closing 'p' tags that didn't get copied) and the second does not, no? (The examples from Post #8) Last edited by DiapDealer; 07-19-2012 at 08:51 AM. |
|
![]() |
![]() |
![]() |
Tags |
div, epub validation |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Epub validation error | Pixie25 | ePub | 13 | 09-18-2012 09:39 AM |
epub validation error | adetutuijose | ePub | 12 | 01-14-2012 10:05 PM |
Epub Validation Error | DTurner | ePub | 6 | 09-12-2011 05:13 PM |
Help with EPUb validation and closing tags | book24 | ePub | 1 | 05-24-2011 05:16 PM |
epub validation error | sassanik | Sigil | 19 | 12-08-2010 05:46 AM |