Styling CSS with attributes instead of classes

published Sep 05, 2014 09:50   by admin ( last modified Sep 05, 2014 09:49 )

Seems to make a lot of sense. It introduces a level of indirection where you can target styling changes to an attribute in a specific context. You can't do that with a CSS class. That is, you can't say that a class should be styled differently in a specific context, but you can say that an element having a certain attribute should be styled differently in a specific context.

It seems to clean up CSS quite a bit.


 

By creating a new Attribute Module am-Button, we can separate out the styles that are common to all buttons, to those that make a button large, to those that round a button's corners. Not only can we then freely combine these variations (e.g. am-Button='large rounded'), we can also target the attribute itself for any contextual overrides:


Read more: Link - Introducing AM - Attribute Modules for CSS - Glen Maddern: Internet Pro