1
我无法找到关于如何在多行上缩进HTML标签的指南,而我目前使用的解决方案并不能真正让我满意。在多行上缩进HTML标签
想象一下,我们有一个非常长的div
声明,如:
<div data-something data-something-else data-is-html="true" class="html-class another-html-class yet-another-html-class a-class-that-makes-this-declaration-extremely-long" id="just-a-regular-id">
为了避免水平滚动,当我发现这些巨大的线条,我通常缩进它们以下列方式:
<div
data-something
data-something-else
data-is-html="true"
class="html-class another-html-class yet-another-html-class a-class-that-makes-
this-declaration-extremely-long"
id="just-a-regular-id"
>
<p>Some element inside the DIV</p>
</div>
我认为在可读性方面工作得很好,但我有一些担忧。
- 这种方式是否被认为是一种良好做法?
- 您是否会发现更具可读性的结束
>
以最后一个元素内联的方式保留在开始的HTML标记中,还是像我在上面的示例中一样在新行中保留? - 你有没有其他的首选方法来处理极长的HTML声明?
如果你知道一些关于HTML格式指南的好资源,那么可以分享,因为我没有在网上找到任何具体的东西。