问题描述
我想知道是否可以像HTML5中的XHTML那样编写自闭元素,例如<input type="email">
可以是<input type="email" />
,它是否仍然有效?这是编码HTML5网页的正确方法吗?
I was wondering if I can write self closing elements like in XHTML in HTML5, for example, <input type="email">
can be <input type="email" />
, and will it still validate? And is this the correct way to code HTML5 web pages?
推荐答案
HTML5可以编码为XHTML或HTML4.这种方式很灵活.
HTML5 can either be coded as XHTML, or as HTML 4. It's flexible that way.
这是正确的方法,这是一种偏爱.我怀疑许多进入标准的Web设计人员都习惯于XHTML,并且可能会继续以这种方式进行编码.
As to which is the correct way, that's a preference. I suspect that many web designers into standards are used to XHTML and will probably continue to code that way.
您可以直接转到: http://html5.validator.nu/来验证您的代码,或者如果您具有正确的doctype,则W3C官方网站将为您使用它.
You can go straight to: http://html5.validator.nu/ to validate your code, or if you have the right doctype, the official W3C site will use it for you.
这篇关于XHTML自动关闭元素在HTML5中仍然有效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!