My style sheets are bloated mainly because so many styles are identical except for one attribute.
Is there a way of encapsulating the commonality?
encapsulation
- Albert Wiersch
- Site Admin
- Posts: 3783
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
- Contact:
Re: encapsulation
Do you mean an automated way? If so then I am not aware of one but there could be something out there (though I suspect something like this would be very difficult to do automatically without unexpected side effects and other issues).
Otherwise you may have to manually re-design your styles so that they make better use inheritance in order to eliminate or reduce the unnecessary duplicate style properties.
Putting common properties in a separate class might help as well. You could then assign HTML elements that common class plus other classes... but making use of inheritance (if you can) and good design (good CSS classes, etc.) would be the best option.
Otherwise you may have to manually re-design your styles so that they make better use inheritance in order to eliminate or reduce the unnecessary duplicate style properties.
Putting common properties in a separate class might help as well. You could then assign HTML elements that common class plus other classes... but making use of inheritance (if you can) and good design (good CSS classes, etc.) would be the best option.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
- roedygr
- Rank V - Professional
- Posts: 367
- Joined: Fri Feb 17, 2006 5:22 am
- Location: Victoria BC Canada
- Contact:
Re: encapsulation
What do you mean by "the cascade"?
- Albert Wiersch
- Site Admin
- Posts: 3783
- Joined: Sat Dec 11, 2004 9:23 am
- Location: Near Dallas, TX
- Contact:
Re: encapsulation
Hello,
This explains it well:
https://developer.mozilla.org/en-US/doc ... nheritance
Though it seems I meant to say inheritance (and will update my post). You can use inheritance to limit the amount of properties you set and simplify your CSS.
This explains it well:
https://developer.mozilla.org/en-US/doc ... nheritance
Though it seems I meant to say inheritance (and will update my post). You can use inheritance to limit the amount of properties you set and simplify your CSS.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
- RSteinwand
- Rank VI - Professional
- Posts: 596
- Joined: Mon Jun 09, 2008 2:12 pm
- Location: Fargo, ND
- Contact:
Re: encapsulation
I found this interesting: http://www.stubbornella.org/content/201 ... nt-page-1/
Rick