&br; br的主要区别是什么?和< br/> [英] What is the main difference of <br> and <br />

查看:184
本文介绍了&br; br的主要区别是什么?和< br/>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

html标记中的<br><br />之间的主要区别是什么?有人可以解释两者的主要区别,因为这让我感到困惑.预先感谢您的所有评论. :)

What is the main difference between <br> and <br /> in html markup? Can someone explain the main difference of the two because it's confusing to me. Thanks in advance for all of your comments. :)

推荐答案

在实践中,</br>不存在.只需<br><br />.

In practice, </br> does not exist. Just <br> or <br />.

但是,区别在于位置,并且对所有XML标签都是通用的. <TAG_NAME>指示标签的开始,而</TAG_NAME>指示标签的结束.如果在标签之间不使用任何标签,则可以使用自闭合标签或空标签,该标签将开始和结束结合在一起.看起来像<TAG_NAME />.

However, the difference is the position, and is universal for all XML tags. <TAG_NAME> indicates the beginning of a tag, and </TAG_NAME> indicates the end of a tag. When a tag is used with nothing between it, then a self-closing, or null tag can be used, which combines the beginning and end. It looks like <TAG_NAME />.

在XML中,任何标签都可以是自动关闭的,但是对于HTML,只有这样定义的标签才应使用.因此,永远不要执行<div />,而应该使用<div></div>,即使它为空.如前所述,HTML中的一些自闭标签是<br />,还有<param /><input /><track />之类的东西.您可以在此处查看完整列表.

In XML, any tag can be self closing, however, with HTML, only tags which are defined as such should be used that way. So you should never do <div />, instead you should use <div></div>, even if it's empty. Some self closing tags in HTML are, as already noted, <br />, also things like <param />, <input /> and <track />. You can view the full list here.

因此,基本上,上面链接中的元素被允许自关闭.它们通常具有指示其数据的属性,但内部不允许有其他元素.其他元素(其中可以包含其他元素)需要同时填写<TAG></TAG>.

So, basically, elements in the link above are allowed to be self closing. They often have attributes to indicate their data, but no additional elements are allowed inside of them. Other elements, which can have additional elements inside of them require both <TAG> and </TAG> to be complete.

请注意,在不太严格的规则下,在HTML中,自闭标签不需要结尾斜杠,因此<br>等效于<br />.但是,后一种形式是首选,并且看起来更干净.另外,任何不是自封闭的标签,也不是封闭属性(即具有</TAG>)的标签,将引起您的噩梦,因为元素将具有一个应该是同级的父级.

Note that under less strict rules, in HTML, self closing tags do not require the ending slash, so <br> is equivalent to <br />. However, the latter form is preferred, and much cleaner looking. Also, any tags that aren't self closing, that aren't closed property (i.e. has a </TAG>) will cause you a nightmare because elements will have a parent who should be a sibling.

希望有帮助.

这篇关于&br; br的主要区别是什么?和&lt; br/&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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