17
During the Paint from the document by the browser the order of the properties of the CSS classes may interfere in how we perceive the page’s "assembly"?
Especially in slower connections, we literally see the styles being applied to the elements, so the order of the properties we use in the classes should be something to consider when writing the CSS? I mean, the order of attributes in the classes interferes with CSSOM and how the Render Tree is built by the browser?
I saw this image and wondered if the order of CSS styles can interfere with Paint page...
Example: (considering the slow rendering/connections/performance and UX/UI tree)
Let’s say we have the following CSS that was written "randomly" with no concern for the attributes.
.container {
background: rgba(0,0,0,0.25);
width: 100%;
height: 100%;
text-align: center;
padding-top: 100px;
display: block;
position: absolute;
z-index: 2;
font-family: consola;
font-size: 1rem;
}
And we have another CSS that was written thinking in the order that the layout of the elements is built:
.container {
display: block;
position: absolute;
width: 100%;
height: 100%;
padding-top: 100px;
z-index: 2;
background: rgba(0,0,0,0.25);
font-family: consola;
font-size: 1rem;
text-align: center;
}
There should be a care in the order of these attributes within the classes, they influence how the Render Tree and the page’s Paint happens? Is there any good practice?
Which attributes are more important than others in the CSS and which are interpreted with priority or not?
Or it doesn’t exist, it’s totally irrelevant and you shouldn’t waste time on it?
OBS: I know that very probably each browser can understand this in a different way, so I do not distinguish about a browser or other ok, any information is valid.
The order you have of class properties won’t matter when rendering, the DOM releases your node when everything is applied.
– Pedro Lins