Forums

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

Home Forums CSS Shortening CSS Reply To: Shortening CSS

#241255
Senff
Participant

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: http://codepen.io/senff/pen/eZbMVo

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!