Is it sometimes bad to use lt;BR /gt;?(有时使用lt;BR/gt;是不是很糟糕?)
问题描述
使用 <BR/>
标签有时是不是很糟糕?
Is it sometimes bad to use <BR/>
tags?
我之所以这么问,是因为我的开发团队给我的第一个建议是:不要使用 <BR/>
;相反,使用样式.但为什么?使用 <BR/>
标签会产生负面影响吗?
I ask because some of the first advice my development team gave me was this: Don't use <BR/>
; instead, use styles. But why? Are there negative outcomes when using <BR/>
tags?
推荐答案
不使用<br>
的主要原因是不是语义.如果您希望两个项目位于不同的视觉块中,您可能希望它们位于不同的逻辑块中.
The main reason for not using <br>
is that it's not semantic. If you want two items in different visual blocks, you probably want them in different logical blocks.
在大多数情况下,这意味着只使用不同的元素,例如 <p>Stuff</p><p>Other stuff</p>
,然后使用 CSS 来分隔块正确退出.
In most cases this means just using different elements, for example <p>Stuff</p><p>Other stuff</p>
, and then using CSS to space the blocks out properly.
在某些情况下 <br>
在语义上是有效的,即换行符是您发送的数据的部分的情况.这实际上仅限于 2 个用例 - 诗歌和邮寄地址.
There are cases where <br>
is semantically valid, i.e. cases where the line break is part of the data you're sending. This is really only limited to 2 use cases - poetry and mailing addresses.
这篇关于有时使用<BR/>是不是很糟糕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有时使用<BR/>是不是很糟糕?


- Fetch API 如何获取响应体? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 失败的 Canvas 360 jquery 插件 2022-01-01