ITMS-9000"元素" img"不允许在这里;预期..."

时间:2016-07-15 07:19:51

标签: epub

尝试让ePub文件通过Apple的ePub检查程序,但多次出现两次错误。

(1)element" img"不允许在这里;期待元素......

这是页面上的编码:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../Styles/Style.css" type="text/css" rel="stylesheet"/>
<title></title>
</head>
<body>
<h2>Tokyo</h2>
<p>Japan is made up of five main islands: Hokkaido, Honshu, Shikoku, Kyushu, and Okinawa. Over three-quarters of the 127 million people in Japan live on Honshu, the largest and most developed island. Tokyo, the capital, lies on its eastern shore.</p>
<img alt="Tokyo Metropolis" src="../Images/Tokyo-Metropolis.jpg"/>
<p>Tokyo Metropolis, one of Japan’s 47 prefectures, is comprised of two areas: the <a class="hook" id="Special-Wards-23">23 special wards</a>, which together make up what most consider to be Tokyo, and the rest—the cities and towns that lie to the west. It is best thought of as a constellation of cities that have, over the course of time, merged into one vast urban sprawl which is home to over 13 million people.</p>

我正确插入了alt标签,它在iBooks中显示正确。

img的CSS如下:

img
{
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 15px;
margin-bottom: 15px;
padding: 1px;
border: 1px solid #021a40;
background-color: #FFFFFF;
}

我已经在众多论坛上四处看看,但我没有明白为什么我会收到此错误。

(2)相同的错误,但与标签有关(&#34;元素&#34; ul&#34;此处不允许;预期的结束标签或元素&#34; li&#34; ......&# 34)

这里的HTML ...

<ul>
<li><a href="../Text/Introduction.xhtml"><b>Introduction</b></a></li>
    <ul>
    <li><a href="../Text/Tokyo.xhtml">Tokyo</a></li>
    <li><a href="../Text/A%20Brief%20History.xhtml">A Brief History</a></li>
        <ul>
        <li><a href="../Text/A%20Brief%20History.xhtml#The-Emergence-of-Japan">The Emergence of Japan</a></li>

[Html剪短,因为它是一个目录而且很长]。

我认为这是因为我有嵌套列表,但这在iBooks中运行良好,所以我不知道它为什么会在验证时导致错误。

我非常感谢你的帮助!

1 个答案:

答案 0 :(得分:2)

第二个是明确的:列表只能包含列表项。就是这样。
你说“这在iBooks中完美运行”,但事实并非如此。它并不完美。这只是应用程序的错误处理例程碰巧以这样的方式处理它,结果看起来大致像你期望的那样。这在其他机器,应用程序的其他版本等上是不一样的。避免这样的错误。

第一条错误信息更加微妙 该文件将自己标识为什么版本的HTML? 如果它是XHTML 1.x或HTML 4.x严格,则在正文级别正式不允许使用纯文本和内联元素。不要问我为什么,我不知道。
如果文件版本是HTML 4.01 Transitional或HTML5(或XHTML等价物),那么图像作为正文的子项就可以了。

如果有人能告诉我为什么存在这种差异,我会很高兴的!

至于解决方案,如果你不能将HTML版本更改为HTML5或XHTML5,那么只需将所有内容放在一个大的div中即可。只需将<div>放在<body>之后,</div>放在</body>之前。