i love to reference multiple classes for a button in an external stylesheet in order to save time and to make it clear.
i have <button class= class1 class2 class3 class4 class5></button>

how can i reference class1 class2 class3 class4 in a separate stylesheet?

Recommended Answers

All 4 Replies

Put your classes in test.css and put the following in the head of the page you want to use them:

<link rel="stylesheet" href="test.css">

and one important thing for your information it would be better to surrond the classes by "" . I think it is the right way to do it and you will reduce any further confusing.

Use fiddle to execute your code in easy way.

Member Avatar

Having a huge number of classes for a single element can become very hard to maintain and it can inject unexpected 'specificity' side effects, depending on how it's implemented. Maybe have a look at BEM, e.g. https://css-tricks.com/bem-101/ - just a thought. BEM isn't the last word about the "correct" methodology, but it's quite useful in getting you to think about how to streamline your styling making them 'maintainable'. You may also find pre-processing interesting (LESS, SASS, etc.): http://www.sitepoint.com/6-current-options-css-preprocessors/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.