The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS css coding

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #34328

    i have been thinking off trying something a little different with css coding (not sure if people already use this in practice) but was wondering if anyone either does do this or if there is some reason i shouldn’t do it.

    the reason i came up with this is i was tired of writing specific styles for one element that would utilise styles from a few different elements, so i thought instead of writing a new generic style write a lot of smaller ones that get reused easily.

    so some example css would be:

    .lightgrey {
    .bold {
    .italic {
    .upper {
    .icon {
    background: url(‘../img/icons.png’) no-repeat;
    .arrow {
    background-position:-35px 0px
    so whenever i need some specific style (that doesnt come under an existing style), I just call it up like:

    <p class=”lightgrey bold italic upper”>Some text<⁄p>


    <span class=”icon arrow”><⁄span>

    that way i see it, the css gets reused very easily, but what tends to happen is (as above) the class gets packed with styles sometimes 4 or 5 of them. so my worry is, would this have an impact on load times and possible be a nightmare to maintain.

    Am I completely wrong in writing code like this? Has anyone written code like this before and have some feedback on maintenance/page load etc?


    It isn’t great semantically. What happens if you want to change the font-style of an element? Usually you would just do so in your CSS, but with this method you would also have to change the class names in your HTML also.


    well main styles (font etc) would be set on the p element, but the above really is just for specific one off elements not meant to be used for the entire styling.


    appreciate the feedback though


    Have a look at this article Chris wrote:


    thanks good article.



    “What happens if you want to change the font-style of an element?”

    I do a mixture of that. I don’t have “.light-grey”, but I do have “.pown” for example (== only visible to owner, colors stuff red). attempting to make my own CMS, I simply don’t want to have a billion class names, so my “design” is rather LEGO brick like. I never want to change the style of “that box on this page”, I want to change the style of UI elements. and that I can do just fine with that approach.

    one thing in that article really made no sense to me, about .left for floating something left: I have .tleft and .tcent for aligning text, I use it for table cells usually. I do NOT want to have “.stats_something .hit_count {text-align:right;}” in my CSS, sorry! I’d rather have class=”tleft” in my HTML. if I wanted to align it differently, that would always be an effect of changes in the HTML, there is no way I would change some things just via CSS. so that sounds a bit theoretical for me, especially since it fails to answer how else to do it. specify a new class for something just to align it like you align a thousand other things? or put it in a wrapper? huh. try creating a stylesheet for hundreds, maybe thousands of pages while being semantic and staying under 50k, good luck :/

Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘CSS’ is closed to new topics and replies.