HTML5验证错误:在此上下文中,元素源不允许作为音频的子元素 [英] HTML5 validation error: Element source not allowed as a child element of audio in this context

查看:294
本文介绍了HTML5验证错误:在此上下文中,元素源不允许作为音频的子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的作业中的代码片段。我已经检查了w3样本 http://www.w3schools.com/html/html5_audio.asp 并且格式正确。我是因为这些错误而疯了还是我错过了什么?

This is a snippet of code from my assignment. I've checked the w3 samples http://www.w3schools.com/html/html5_audio.asp and it is formatted correctly. Am I just going crazy because of these errors or did I miss something?

我相信这是HTML5 来源元素不喜欢类型的写入方式,但我怎么做呢?如果你们看到我遗漏的任何内容,请告诉我。

I believe it's that the HTML5 source element doesn't like how the type is written in but how else would I do it? Please let me know if you guys see anything I'm just missing.

<li>.ogg(HTML5 <code>audio</code> tag)
            <ul>
                <li style="list-style-type:none;">

                    <audio controls>
    `                   <source src="/audio1/horse.ogg" type="audio/ogg">
                        <!-- IE Support -->
                        <source src="http://itwp.macomb.edu/wannerj/itwp1000/sounds/horse.mp3" type="audio/mpeg">
                        Your browser does not support the audio element.
                    </audio>
                </li>
            </ul>
        </li>


推荐答案

W3C HTML Checker的维护者。问题是你的HTML中有一个流浪的`(反引号)字符,在< audio controls> 开始标记,在< source src =/ audio1 / horse.oggtype =audio / ogg> 开始标记之前。

Maintainer of the W3C HTML Checker here. The problem is that you have a stray ` (backtick) character in your HTML, on the line after the <audio controls> start tag and before the <source src="/audio1/horse.ogg" type="audio/ogg"> start tag.

删除`字符,错误将消失。

Remove that ` character and the error will disappear.

验证者在这种情况下显示错误消息的原因是当它看到时`字符,它将其解释为文本内容(后备内容),以便在不支持 audio 元素的浏览器中向用户显示;也就是说,与问题代码段中的您的浏览器不支持音频元素文本相同。

The reason the validator is showing that error message in this case is that when it sees that ` character, it interprets it as text content (fallback content) to show to users in browsers that don’t support the audio element; that is, the same as the "Your browser does not support the audio element" text in the snippet in the question.

但是如果 audio 元素具有此类文本内容,则HTML规范中的规则规定不允许任何元素遵循该文本内容。因此,当检查程序在这种情况下看到 source 元素时,它会发出一条错误消息,指出不允许 source 元素。

But if an audio element has such text content, then the rules in the HTML spec state that no elements are allowed to follow that text content. So when the checker sees the source element in this case, it emits an error message saying the source element is not allowed.

对不起,检查员在这里没有给出更好的错误信息,以帮助您查明问题;例如,如果它说的话会好得多:

I’m sorry the checker doesn’t give a better error message here to help you pinpoint the problem; for example, it would be much better if it said something like:


来源元素,因为这个音频元素
已经有文本内容(`);删除文本内容或移动它
以跟随元素。

The source element is not allowed here because this audio element already has text content (`); remove the text content or move it to follow the source element.

但是当前检查器代码的设计使得它很难产生更有用的详细错误消息。

But the current design of the code for the checker makes it very difficult to have it produce a more-helpful detailed error message like that.

这篇关于HTML5验证错误:在此上下文中,元素源不允许作为音频的子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆