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格式指南的好資源,那麼可以分享,因爲我沒有在網上找到任何具體的東西。