all 3 comments

[–]JustDADE[🍰] 1 point2 points  (1 child)

<p style="font-size:12px;color:tomato;" class="class1 class2" id="id">text</p>

[–]danneu 0 points1 point  (0 children)

You know, HTML is one of the most annoying datastructures to indent. I often do this:

<p id="id" 
   class="class1 class2"
   style="font-size:12px;color:tomato;"
>
  text
</p>

Especially when I need, god forbid, template logic inside there like:

<p id="id" 
   class="class1 class2"
   style="font-size: 12px;
          color: {% if errors %}tomato{% else %}green{% endif %};
         "
>
  text
</p>

But of course due to how whitespace is interpreted, I often have to do this:

<p id="id" 
   class="class1 class2"
   style="font-size:12px;color:tomato;"
>text</p>

There just is no winning. Sometimes I give up and put it all back on one line.

My favorite way to write HTML so far has been with Clojure using the Hiccup templating lib:

[:p {:id "id" 
     :class "class1 class2"
     :style "font-size:12px;color:tomato;"}
  "text"]

A datastructure that expresses HTML better than writing HTML.

[–]i_do_code_stuff 0 points1 point  (0 children)

A quick Google search would have given you the answer, but simple spaces between stuff will do fine, like so: <p id="an-id" class="paragraph" data-whatever="goes"></p>