如何在XHTML中使用HTML5功能 [英] How to use HTML5 features with XHTML

查看:96
本文介绍了如何在XHTML中使用HTML5功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些网页编程方面的帮助。我必须从学校完成这项任务,教授已详细介绍了构建方法。其中之一是我的网站应符合XHTML(严格或过渡)。另一个是我需要使用至少一个HTML5功能。如果没有任何新标签会使用XHTML验证,我该如何使用HTML5功能?

I need some help with web programming. I have to do this assignment from school and the prof has given details on the structuring. One of them is that my site should be XHTML compliant (Strict or Transitional). Another is that I need to use at least one HTML5 feature. How do I use an HTML5 feature if none of the new tags will validate with XHTML?

我将其声明为XHTML 1.0 Transitional。

I am declaring it as XHTML 1.0 Transitional.

这是我的HTML代码,我遇到了麻烦。

Here is my HTML code where I am having trouble.

<body id="index" class="home">
<header id="banner" class="body">
<h1><a href="#">Header1 </a></h1>

<nav><ul>
<li class="active"><a href="#">home</a></li>
<li><a href="#">portfolio</a></li>
<li><a href="#">blog</a></li>
<li><a href="#">contact</a></li>
</ul></nav>

</header>
</body>

在包含header和nav的行中,它表示元素未定义,并且没有属性id并在头上课。请帮助。

In the line with header and nav, it says the elements are undefined and that there are no attributes id and class in header. Please help.

感谢。

推荐答案

这似乎是最有意义的是,您需要使用 XHTML线性化

The interpretation of the assignment that seems to make most sense is that you are required to use XHTML linearization of HTML5, also known as XHTML5. This simply means that you use HTML5 like anyone else but do that using general XML principles.

在示例中,这意味着以下标记:

In the example case, this would mean the following markup:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body id="index" class="home">
<header id="banner" class="body">
<h1><a href="#">Header1 </a></h1>

<nav><ul>
<li class="active"><a href="#">home</a></li>
<li><a href="#">portfolio</a></li>
<li><a href="#">blog</a></li>
<li><a href="#">contact</a></li>
</ul></nav>

</header>
</body>
</html>

XHTML 1.0 doctypes是完全不同的。他们定义了固定版本的HTML,因此您不能在静态标记中使用这些版本所不允许的任何内容,即HTML5中与XHTML 1.0和HTML 4.01相比的新内容(这是HTML5功能可能意味着的内容分配)。 符合XHTML(严格或过渡)的要求是不明确的,但如果要专门引用XHTML 1.0,那么该任务是自相矛盾的(除非您应该使用客户端脚本来获取HTML5功能)。

The XHTML 1.0 doctypes are something quite different. They define fixed versions of HTML, so you cannot use, in the static markup, anything not allowed by those versions, i.e. anything that is new in HTML5 as compared with XHTML 1.0 and HTML 4.01 (which is what "HTML5 feature" probably means in the assignment). The requirement "XHTML compliant (Strict or Transitional)" is obscure, but if it is meant to refer to XHTML 1.0 specifically, then the assignment is self-contradictory (unless you are supposed to use client-side scripting to get to "HTML5 features").

(由于@Alohci的评论,这个回答基本上被重写了。)

(This answer was largely rewritten thanks to @Alohci’s comments.)

这篇关于如何在XHTML中使用HTML5功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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