CSS Classes vs Grouped IDs Performance -
searched high , low. quite familiar css classes vs ids (vs selectors) performance, there lots of literature, including in these forums regarding topic.
i ask whether better use css class or group ids, either performance or other advantage.
example;
the html;
<p class="para-format">you know something?</p> <p class="para-format">this good</p> .... <p class="para-format">the last paragraph</p>
vs
<p id="para-format-01">you know something?</p> <p id="para-format-02">this good</p> .... <p id="para-format-0n">the last paragraph</p>
the css;
.para-format {color: #000000; margin: 0 auto; ...}
vs
#para-format-01, #para-format-02, ..., #para-format-0n {color: #000000; margin: 0 auto; ...}
i know isn't best example i'm asking.
thanks , regards, - botrot
there no measurable difference between two, , since purpose of class duplicate same style on multiple elements, semantically better use class. case should overly concerned difference between 2 when using javascript select elements id or class name, , when talking hundreds of elements. if ever point negligible performance benefit gain offset kilobytes in stylesheet marginally increase load times. neither case going impact performance massively, 1 if give migraine looking @ it.
for own sanity, use classes don't have update css selector whenever add new element.
Comments
Post a Comment