CSS Tag Order and Placement


When modifying an HTML document with CSS, is there a particular order that the tags should be arranged? For example, the font-family attribute should come before color, or text-size or any of the various options available? When changing a paragraph style, does the box content come before text attributes. It feels like a jumbled mess of font-size; text-transform; width; color; float; font-family;etc… Just curious if there is a reason or order.


No. Any order will do.

selector {
    property: value;
    property: value;
    property: value;

(Pretend the properties are all different.) Every declaration will apply to the selector in every instance within the document. The order the declarations are written has no bearing.

What is important is the order of the cascade (the order in which selector rules are written). That has a huge impact.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.