使用<BR/>标签有时候是不好的?
我问,因为开发团队给我的第一条建议是:不要使用<BR/> ; 而是使用样式。 但为什么? 使用<BR/>标签时是否有负面结果?
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?
最满意答案
不使用<br>主要原因是它不是语义 。 如果你想要两个不同的视觉区块,你可能希望它们在不同的逻辑块。
在大多数情况下,这意味着只是使用不同的元素,例如<p>Stuff</p><p>Other stuff</p> ,然后使用CSS将块正确放置。
有些情况下<br>具有语义有效性,即换行符是发送数据的一部分 。 这真的只限于2个用例 - 诗歌和邮寄地址。
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.
更多推荐
发布评论