我正在尝试编写干净、可访问的 HTML 代码,以适应遵循此标准的屏幕阅读器和其他辅助技术:https://www.w3.org/WAI/standards-guidelines/wcag/
我想在我的网页上显示外部视频(在我的例子中是 YouTube 视频),并且我不确定是否需要将 YouTube 视频包装在
video
标签内。
这是我当前的 HTML:
<!DOCTYPE html>
<html>
<body>
<video>
<iframe width="420" height="345" src="https://www.youtube.com/embed/tgbNymZ7vqY"></iframe>
</video>
</body>
</html>
此 HTML 正确吗?还是我在这种情况下不需要
<video>
?我需要改进此 HTML 吗?
在您的代码中,视频未显示为输出。
试试这个代码:
<iframe width="560" height="315" src="https://www.youtube.com/embed/tgbNymZ7vqY" title="YouTube video player"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
在我的代码中,我没有像您所说的那样使用
video
标签。