0

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?

5
Contributors
4
Replies
13
Views
1 Year
Discussion Span
Last Post by diafol
1

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">
0

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.

1

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/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.