我应该使用HTML5语法吗? [英] Should I Use HTML5 Syntax?

查看:100
本文介绍了我应该使用HTML5语法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个参考,以确保我正确地禁用了一个元素。当XHTML问世时,我总是被教导禁用这样的元素:

I was looking for a reference to make sure I was disabling an element correctly. When XHTML came out, I was always taught to disable an element like so:

<input type="submit" disabled="disabled" />

XHTML是通过遵循更多规则来使HTML语法更严格的。但是,然后我去了W3C的HTML5工作草案并注意到跟随他们的布尔属性(例如禁用):

XHTML was all about making the HTML syntax more strict by following more rules. But, then I went to the HTML5 working draft on W3C and noticed the following on their boolean attributes (such as disabled):

<label><input type=checkbox checked name=cheese disabled> Cheese</label>

我的意思是,看起来即将推出的HTML5语法会更松散,就像旧学校的日子一样在XHTML之前。也许我错过了一些东西。

I mean, it looks like the upcoming HTML5 syntax will be much more loose, like the old school days before XHTML. Maybe I'm missing something though.

所以,这里有一个问题:我应该使用HTML5语法风格(W3C工作草案中的那种)来获取新的HTML写在我的网站上(我正在使用HTML5 doctype)?

So, here's the question: Should I use the HTML5 syntax style (the one in the W3C working draft) for new HTML that I write on my site (I am using the HTML5 doctype)?

推荐答案


是关于制作遵循更多规则,HTML语法更严格。

was all about making the HTML syntax more strict by following more rules.

实际上规则较少。他们删除了例外。例如,除非值符合某些条件,否则必须引用属性值变为必须引用属性值。

Fewer rules actually. They removed exceptions. For example "Attribute values must be quoted unless the value conforms to certain conditions" became "Attribute values must be quoted".

当然,然后添加HTML兼容性准则,因为XHTML从未真正起飞,几乎每个人都将其作为text / html服务,导致不能拥有内容的元素必须省略结束标记变为不能拥有内容的元素必须省略结束标记并使用自我关闭标记语法代替。

Of course, you then add in the HTML compatibility guidelines, because XHTML never really took off and almost everyone served it as text/html resulting in "Elements that cannot have content must have the end tag omitted" becoming "Elements that cannot have content must have the end tag omitted and use self-closing tag syntax instead".


我的意思是,看起来即将推出的HTML5语法将更加松散,就像XHTML之前的旧学校日子一样。

I mean, it looks like the upcoming HTML5 syntax will be much more loose, like the old school days before XHTML.

语法规则基本上包含HTML和XHTML中允许的所有内容,两者之间的差异落在XHTML端。 (例如< foo /> 表示< foo> 而非< foo> ;& gt; )。

The syntax rules basically encompass everything that was allowed in HTML and XHTML with differences between the two falling on the XHTML side. (e.g. <foo /> means <foo> and not <foo>&gt;).


我应该使用HTML5语法风格(W3C工作方式)草稿)

Should I use the HTML5 syntax style (the one in the W3C working draft)

关于你使用的风格的问题有些主观。遗漏可选的事物和非事物的明确性都是有道理的。

The question as to the style you use is somewhat subjective. There are merits to both the conciseness of leaving out things that are optional and the explicitness of not.

如果您使用HTML5,那么您应该编写有效的HTML5。您给出的示例并不是唯一可接受的方法。

If you use HTML5 then you should write valid HTML5. The example you give is not the only acceptable approach though.

这篇关于我应该使用HTML5语法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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