I just started doing web development a few months ago. I know HTML and I know how page layout should be semantically correct (without using tables for layouts, using new semantic elements from HTML5 correctly, etc.). I try to stick to the W3C design guidelines. However, it's hard for me to write “good” CSS.
I know about using efficient selectors like a child selector, not a descendant selector, etc. My problem is that I feel that my CSS does not match my markup semantics. It is assumed that CSS can be reused, which means that the same class can be used for multiple elements on multiple pages. But the CSS classes that I write apply only to a few elements (often only on one page) and are never used again. I often write the same styles, but with minor modifications, for many classes. This is contrary to the principle of DRY development.
Am I not using CSS in full? What are some ways to make my styles reusable without doing things like .right-align { } .blue-text { }?
source
share