使用< BR />?有时不好吗? [英] Is it sometimes bad to use <BR />?

查看:123
本文介绍了使用< BR />?有时不好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用< BR /> 标记有时是不好的?

我的开发团队给我的第一条建议是:不要使用< BR /> ;相反,使用样式。但为什么?当使用< BR /> 标签时,是否会产生负面结果?

解决方案

不使用< br> 的主要原因是它不是语义。如果你想在不同的视觉块中使用两个项目,你可能需要它们在不同的逻辑块中。



在大多数情况下,这意味着只使用不同的元素,例如< p> Stuff< / p>< p>其他内容< / p> ,然后使用CSS将块正确地分隔开。 $ b

在某些情况下,< br> 在语义上是有效的,即换行符是数据的部分重发。这实际上仅限于2个用例 - 诗歌和邮寄地址。


Is it sometimes bad to use <BR/> tags?

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?

解决方案

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.

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.

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.

这篇关于使用&lt; BR /&gt;?有时不好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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