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

Home Forums CSS Shortening CSS

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

    Hi, I’m just a beginner coder – sorry. I have taken some code and kind of repeated it to get the effect I want. However, its lines and lines of CSS. I know there is a way of shortening it down, but I can’t get it to work.

    Its here at Code pen…

    Any help would be greatly appreciated




    Lines and lines of code? Welcome to coding. ;)

    The main thing you can do to shorten it, is to not assign styles to every single element individually. Instead, give all those elements a certain classname, and then assign all the common stuff (in other words, the properties they all share) to that classname.

    Everything that certain elements share, should be put in a class, and put those properties in a class.

    Here’s a start:

    It’s far from optimized, and there’s something to say about a number of other things (using IDs instead of classes for example), but this example is just to give you an idea how you can make elements share properties, instead of assigning the same properties to each individual element.

    Good luck!


    Thanks man, I’m beginning to understand it :)

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