XHTML自动关闭元素在HTML5中仍然有效吗? [英] Are XHTML self closing elements still valid in HTML5?

查看:88
本文介绍了XHTML自动关闭元素在HTML5中仍然有效吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以像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中仍然有效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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