程序员

html中br和br/的区别介绍

作者:admin 2021-06-15 我要评论

answer from stackflow: Simply br is sufficient. The other forms are there for compatibility with XHTML; to make it possible to write the same code as ...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)
answer from stackflow:

Simply <br> is sufficient.

The other forms are there for compatibility with XHTML; to make it possible to write the same code as XHTML, and have it also work as HTML. Some systems that generate HTML may be based on XML generators, and thus not have the ability to output just a bare <br> tag; if you're using such a system, it's fine to use <br/>, it's just not necessary if you don't need to do it.

Very few people actually use XHTML, however. You need to serve your content as application/xhtml+xml for it to be interpreted as XHTML, and that will not work in IE (it will also mean that any small error you make will prevent your page from being displayed, in browsers that do support XHTML). So, most of what looks like XHTML on the web is actually being served, and interpreted, as HTML. See Serving XHTML as text/html Considered Harmful for some more information.

意思就是说:HTML中的规定是<br>空标签,没有结束符,但是在XHTML中,规定是<br/>开始标签后面紧跟结束标签。

在 XHTML 中,<br> 标签必须被正确地关闭,比如这样:<br />。<br> 标签是空标签(意味着它没有结束标签,因此这是错误的:<br></br>)。在 XHTML 中,把结束标签放在开始标签中,也就是 <br />。

原文链接:https://m.jb51.net/web/105538.html

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • html中br和br/的区别介绍

    html中br和br/的区别介绍

  • iframe 多层嵌套 无限嵌套 高度自适应

    iframe 多层嵌套 无限嵌套 高度自适应

  • src或者css背景图的url值为base64编码

    src或者css背景图的url值为base64编码

  • 从案例到底层原理,彻底理解volatile可

    从案例到底层原理,彻底理解volatile可

腾讯云代理商
精彩导读
海外云服务器
热门资讯
腾讯云代理商