raulricardo21
raulricardo21

Reputation: 2499

How to keep html line code short?

Sometimes, you need many classes, other properties and maybe a couple of data attributes on a single tag.

For example something like this:

<div id="myId" class="class1 class2 class3" data-foo="yadda yaddd" data-bar="more yadda yadda>
    ...
</div>

And I wonder if are there some good practices to keep html code short, and I mean the case when you have so much props/attributes, and I'm not thinking in backend at all or haml, just pure HTML.

Is there some good practice for these cases?

Upvotes: 0

Views: 187

Answers (1)

ray
ray

Reputation: 27245

I generally put each attribute on its own line in cases like this.

<div id="myId"
     class="class1 class2 class3"
     data-foo="yadda yaddd"
     data-bar="more yadda yadda">
     ...
</div>

Upvotes: 5

Related Questions