Reputation: 12429
Is it better to create a class for a single rule (e.g. float:left;) or apply it using inline style?
Upvotes: 0
Views: 105
Reputation: 34853
Better to create a class.
You never know when you will want to use that style again. Having it in a class can make it easier to reuse. For instance, an img.right
class can be used to float
all your images to the right (with the class right).
Inline styles are difficult to override should you want to do so in the future.
Classes on elements make those elements easier to manipulate with javascript and other programming languages.
It keeps you code clean and easy to read, for you and for others.
Upvotes: 3
Reputation: 700592
The layout should be separated from the content, so you should have the style in the stylesheet.
Upvotes: 3
Reputation: 72682
It's never better to use inline styles no matter what for both readability and maintainability.
Same would go for inline JavaScript.
It makes it a lot easier for yourself if you seperate the logic and the view stuff.
Upvotes: 4