为什么一些html开始标记以正斜杠结束? [英] Why does some html beginning-tags end with a forward-slash?

查看:103
本文介绍了为什么一些html开始标记以正斜杠结束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个菜鸟问题,但我需要知道我需要知道什么:)

为什么一些html开始标记以正斜杠结尾?
例如:

 < meta name =keywordscontent =bla bla bla/> 

最后的正斜杠是什么?

另外一些其他标签也有这个功能...我删除了一些没有任何发生的东西。


<在 XHTML中 < foo /> 是<$ c的简写

解决方案 $ C>< FOO>< /富> 。在HTML中,语法是隐藏并标记为不要这样做,因为浏览器不支持它。



如果您正在编写XHTML,但假装它是HTML (因此不支持XHTML的浏览器(如Internet Explorer 8)可以处理它),那么定义为 EMPTY 必须以这种方式表示(并且不是必须的元素)。


This is probably a rookie question, but I need to know what I need to know :)

Why does some html beginning-tags end with a forward-slash ? For example this:

 <meta name="keywords" content="bla bla bla" />

Whats that last forward slash for? What happens if I remove it?

Also some other tags have this as well... I have removed some without anything happening.

解决方案

In XHTML <foo /> is shorthand for <foo></foo>. In HTML the syntax is obscure and marked as "don't do this" as browsers don't support it.

If you are writing XHTML but pretending it is HTML (so that browsers (such as Internet Explorer 8) which don't support XHTML can handle it), then elements defined as EMPTY in the specification must be represented that way (and elements which are not must not).

这篇关于为什么一些html开始标记以正斜杠结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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