Is there any reason to consider XHTML related details for web development for someone who works with HTML4 and plans to work with HTML5?
对于使用HTML4并计划使用HTML5的人来说,是否有任何理由考虑与Web开发相关的XHTML相关细节?
Or was XHTML a "side" development in web technology which is not related to the current mainstream of web development (which I guess is HTML5)?
或者XHTML是Web技术的“侧面”开发,与当前的Web开发主流(我猜是HTML5)无关?
Rationale for asking
要求的理由
The reason I'm asking is that a * answer I previously posted was recently commented on to the effect that "You should NOT use upper case HTML tags". When I asked "why" the commenter pointed me to a couple of articles, both of which gave the reasoning for lowercase-only tag names as "Upper case tag names are not allowed in XHTML" as the main reason.
我问的原因是我之前发布的*答案最近被评论为“你不应该使用大写HTML标签”。当我问“为什么”时,评论者向我指了几篇文章,这两篇文章都给出了仅小写标签名称的推理,因为“XHTML中不允许使用大写标签名称”作为主要原因。
Since I don't currently do web development in XHTML (pure HTML4.0) and only plan to use HTML5 as the next step, I'm interested in whether XHTML should be a factor in assorted decisions I make as far as web development
由于我目前不在XHTML(纯HTML4.0)中进行Web开发,并且只计划使用HTML5作为下一步,我感兴趣的是XHTML是否应该成为我在Web开发中做出的各种决策的一个因素
Please note that this question is NOT asking whether one should use upper or lower case tag names in pure HTML - merely whether the upper-case-tag prohibition in XHTML should be a factor in my decision making, or I should ignore XHTML related rules.
请注意,这个问题并不是要问是否应该在纯HTML中使用大写或小写标记名称 - 仅仅是XHTML中的大写标记禁止是否应该是我决策中的一个因素,或者我应该忽略XHTML相关规则。
4 个解决方案
#1
8
Most of the info you will find on XHTML fails to mention that the whole purpose of XHTML is to be used by both humans and computers for data exchange. XHTML was created so that computers could talk to each other, but in the same time remain readable by humans. The most crazy thing is that various code monks became obsessed with XHTML compliance, without any intend of using the XHTML for data exchange and without understanding what XHTML actually is.
您将在XHTML上找到的大部分信息都未提及XHTML的全部目的是供人和计算机用于数据交换。 XHTML的创建使计算机可以相互通信,但同时仍然可以被人类读取。最疯狂的是,各种代码僧侣都对XHTML合规性着迷,没有任何打算使用XHTML进行数据交换,也不了解XHTML实际上是什么。
Edit: A good example of XHTML use is an airline company publishing its flights. The company can utilize XHTML to produce a single list of flights that will be both consumable be humans visiting online and by services that will read the data for their needs.
编辑:XHTML使用的一个很好的例子是航空公司发布其航班。该公司可以利用XHTML生成单个航班列表,这些航班既可以是人类在线访问,也可以是服务,可以根据需要读取数据。
On the other hand if you own a hair-salon, there is no need for your site to validate against XHTML standards.
另一方面,如果您拥有美发沙龙,则您的网站无需根据XHTML标准进行验证。
#2
2
Directly, there's no reason to take into account XHTML rules when marking up documents for the HTML serialization of HTML5.¹ However, it seems to be the modern practice to use lower case for tags, and that has been partly influenced by XML and XHTML. So if you find yourself working in a large team of developers, it is quite likely that the coding guidelines for the team will mandate lower case just for consistency's sake. So, it might be worth getting into the habit of doing so.
直接地,在为HTML5的HTML序列化标记文档时没有理由考虑XHTML规则.¹但是,对于标记使用小写似乎是现代的做法,并且这部分受到XML和XHTML的影响。因此,如果您发现自己在一个庞大的开发团队中工作,那么团队的编码指南很可能会为了一致性而强制要求小写。所以,养成这样做的习惯可能是值得的。
¹ Note that there's also the possibility of using the XHTML serialization of HTML5, in which case it would matter of course, but I don't think that's what you are asking about.
¹请注意,也有可能使用HTML5的XHTML序列化,在这种情况下它当然很重要,但我不认为这就是你所要求的。
#3
1
As far as I can tell, XHTML was intended to be a kind of combination between the features of HTML and the strictness of XML. For example, in HTML you can write <b><i>test</b></i>
and the browser won't care, it knows what you meant. Whereas in XHTML that would cause an error and block the entire page from showing.
据我所知,XHTML旨在成为HTML特性和XML严格性之间的一种组合。例如,在HTML中,您可以编写 test ,浏览器无关紧要,它知道您的意思。而在XHTML中会导致错误并阻止整个页面显示。
However most browsers just tolerated errors in XHTML as well, so it became kind of pointless.
然而,大多数浏览器也只是容忍XHTML中的错误,所以它变得毫无意义。
Personally, the only reason I can give for choosing to use lowercase tag names rather than uppercase is because I'm too lazy to hold the Shift key and I remapped my CapsLock key to something more useful.
就个人而言,我可以选择使用小写标签名称而不是大写的唯一原因是因为我懒得握住Shift键并且我将我的CapsLock键重新映射到更有用的东西。
#4
1
From what I've personally observed about XHTML, the only "benefit" of it is the versatility—for example, it is my understanding that with relative ease, one can create a custom tag/element or attribute and still validate with XHTML.
从我个人观察到的XHTML来看,它的唯一“好处”就是多功能性 - 例如,我的理解是,相对容易,可以创建自定义标签/元素或属性,并仍然使用XHTML进行验证。
I see no need for custom tags, since if there isn't one that doesn't fit semantically (though the cases are minimal due to HTML5's improvements in semantic markup), you can just use a div
or span
and use a class
or id
to make it "fit." And HTML5 does allow custom attributes anyways.
我认为没有必要使用自定义标签,因为如果没有一个不符合语义的标签(尽管由于HTML5在语义标记方面的改进,案例很少),你可以使用div或span并使用类或id使它“适合”。 HTML5确实允许自定义属性。
So I see no direct relationship—or at least, I don't think there should be one—between HTML5 and XHTML (and anyways, XHTML 1.0 is meant to be a combination of HTML 4 and XML). The spec doesn't recommend one over the other, it just notes the fact that in HTML5, they are case-insensitive.
所以我认为没有直接的关系 - 或者至少,我认为HTML5和XHTML之间不应该存在一个(而且无论如何,XHTML 1.0应该是HTML 4和XML的组合)。规范并不推荐其中一个,它只是注意到在HTML5中它们不区分大小写的事实。
I personally use lowercase tag names for two reasons:
我个人使用小写标签名称有两个原因:
- It's a nuisance to hold shift every time (though one could argue that you hold shift to get the angular brackets, but whatever).
- It's a style preference—I truly think it looks much cleaner with lowercase tag names as well as a lowercase doctype (
<!doctype html>
). Uppercase tag names are really old-fashioned, and you don't really see them anymore. It may just be a thing with newer generation programmers such as myself.
每次举行轮班都很麻烦(尽管有人可能会争辩说你可以保持轮换以获得尖括号,但无论如何)。
这是一种风格偏好 - 我认为它看起来更清晰,包括小写标签名称和小写doctype()。大写标签名称实际上是老式的,你不再真正看到它们了。对于像我这样的新一代程序员来说,这可能就是一件事。
And either way, you should pay no mind to rules that apply to a doctype you're not even working with.
无论哪种方式,您都应该不介意适用于您甚至不使用的doctype的规则。
#1
8
Most of the info you will find on XHTML fails to mention that the whole purpose of XHTML is to be used by both humans and computers for data exchange. XHTML was created so that computers could talk to each other, but in the same time remain readable by humans. The most crazy thing is that various code monks became obsessed with XHTML compliance, without any intend of using the XHTML for data exchange and without understanding what XHTML actually is.
您将在XHTML上找到的大部分信息都未提及XHTML的全部目的是供人和计算机用于数据交换。 XHTML的创建使计算机可以相互通信,但同时仍然可以被人类读取。最疯狂的是,各种代码僧侣都对XHTML合规性着迷,没有任何打算使用XHTML进行数据交换,也不了解XHTML实际上是什么。
Edit: A good example of XHTML use is an airline company publishing its flights. The company can utilize XHTML to produce a single list of flights that will be both consumable be humans visiting online and by services that will read the data for their needs.
编辑:XHTML使用的一个很好的例子是航空公司发布其航班。该公司可以利用XHTML生成单个航班列表,这些航班既可以是人类在线访问,也可以是服务,可以根据需要读取数据。
On the other hand if you own a hair-salon, there is no need for your site to validate against XHTML standards.
另一方面,如果您拥有美发沙龙,则您的网站无需根据XHTML标准进行验证。
#2
2
Directly, there's no reason to take into account XHTML rules when marking up documents for the HTML serialization of HTML5.¹ However, it seems to be the modern practice to use lower case for tags, and that has been partly influenced by XML and XHTML. So if you find yourself working in a large team of developers, it is quite likely that the coding guidelines for the team will mandate lower case just for consistency's sake. So, it might be worth getting into the habit of doing so.
直接地,在为HTML5的HTML序列化标记文档时没有理由考虑XHTML规则.¹但是,对于标记使用小写似乎是现代的做法,并且这部分受到XML和XHTML的影响。因此,如果您发现自己在一个庞大的开发团队中工作,那么团队的编码指南很可能会为了一致性而强制要求小写。所以,养成这样做的习惯可能是值得的。
¹ Note that there's also the possibility of using the XHTML serialization of HTML5, in which case it would matter of course, but I don't think that's what you are asking about.
¹请注意,也有可能使用HTML5的XHTML序列化,在这种情况下它当然很重要,但我不认为这就是你所要求的。
#3
1
As far as I can tell, XHTML was intended to be a kind of combination between the features of HTML and the strictness of XML. For example, in HTML you can write <b><i>test</b></i>
and the browser won't care, it knows what you meant. Whereas in XHTML that would cause an error and block the entire page from showing.
据我所知,XHTML旨在成为HTML特性和XML严格性之间的一种组合。例如,在HTML中,您可以编写 test ,浏览器无关紧要,它知道您的意思。而在XHTML中会导致错误并阻止整个页面显示。
However most browsers just tolerated errors in XHTML as well, so it became kind of pointless.
然而,大多数浏览器也只是容忍XHTML中的错误,所以它变得毫无意义。
Personally, the only reason I can give for choosing to use lowercase tag names rather than uppercase is because I'm too lazy to hold the Shift key and I remapped my CapsLock key to something more useful.
就个人而言,我可以选择使用小写标签名称而不是大写的唯一原因是因为我懒得握住Shift键并且我将我的CapsLock键重新映射到更有用的东西。
#4
1
From what I've personally observed about XHTML, the only "benefit" of it is the versatility—for example, it is my understanding that with relative ease, one can create a custom tag/element or attribute and still validate with XHTML.
从我个人观察到的XHTML来看,它的唯一“好处”就是多功能性 - 例如,我的理解是,相对容易,可以创建自定义标签/元素或属性,并仍然使用XHTML进行验证。
I see no need for custom tags, since if there isn't one that doesn't fit semantically (though the cases are minimal due to HTML5's improvements in semantic markup), you can just use a div
or span
and use a class
or id
to make it "fit." And HTML5 does allow custom attributes anyways.
我认为没有必要使用自定义标签,因为如果没有一个不符合语义的标签(尽管由于HTML5在语义标记方面的改进,案例很少),你可以使用div或span并使用类或id使它“适合”。 HTML5确实允许自定义属性。
So I see no direct relationship—or at least, I don't think there should be one—between HTML5 and XHTML (and anyways, XHTML 1.0 is meant to be a combination of HTML 4 and XML). The spec doesn't recommend one over the other, it just notes the fact that in HTML5, they are case-insensitive.
所以我认为没有直接的关系 - 或者至少,我认为HTML5和XHTML之间不应该存在一个(而且无论如何,XHTML 1.0应该是HTML 4和XML的组合)。规范并不推荐其中一个,它只是注意到在HTML5中它们不区分大小写的事实。
I personally use lowercase tag names for two reasons:
我个人使用小写标签名称有两个原因:
- It's a nuisance to hold shift every time (though one could argue that you hold shift to get the angular brackets, but whatever).
- It's a style preference—I truly think it looks much cleaner with lowercase tag names as well as a lowercase doctype (
<!doctype html>
). Uppercase tag names are really old-fashioned, and you don't really see them anymore. It may just be a thing with newer generation programmers such as myself.
每次举行轮班都很麻烦(尽管有人可能会争辩说你可以保持轮换以获得尖括号,但无论如何)。
这是一种风格偏好 - 我认为它看起来更清晰,包括小写标签名称和小写doctype()。大写标签名称实际上是老式的,你不再真正看到它们了。对于像我这样的新一代程序员来说,这可能就是一件事。
And either way, you should pay no mind to rules that apply to a doctype you're not even working with.
无论哪种方式,您都应该不介意适用于您甚至不使用的doctype的规则。