How do create objects for CSS Get the right granularity

, in the last article, I said, "


hard to plug CSS and HTML into PHP prevents code from getting too boring (DRY) and eventually leads to code bloat, since CSS and HTML require more elaborate object structures than PHP. In fact, PHP templates are not inherently appropriate because each template contains many different HTML, and CSS objects that combine in different ways.

then, I did not explain it, or given the appropriate context. Sorry,

The correct granularity of

is one of the keys to reducing CSS

is on the PHP layer, and the following session stream (from Facebook) may be a single object. All of the logic that detects which HTML to display or hide is contained in an object structure.


a Facebook session stream

usually, developers try to match the CSS’s middle end (between the front end and back end) logic. All of our CSS code that we expect to use for this session stream is contained in a ID wrapped sandbox, such as #story. This will end up bloated and boring code. Why? Because the proper structure of the CSS layer is more refined (smaller in size). In fact, trying to give the CSS structure in the PHP layer is like trying to configure Apache using a database schema. It won’t work.



session stream has many smaller (finer) objects that make up the

so we can see that the flow of the session above is made up of many smaller objects. As we make objects finer (smaller particles), we start to see the same pattern recurring, and then the same objects become more reusable. We began to see that most web sites on the Internet are joined in different ways by the same basic, repetitive patterns. As an added benefit, CSS will become smaller and simpler.

this session stream, a PHP object, is made up of several HTML and CSS objects:

1 title,


5 media blocks


2 link styles


1 comment list


1 action lists


Leave a Reply

Your email address will not be published. Required fields are marked *