DevTools/CSSTips: Difference between revisions

More tips in basics
(Modernize this page)
(More tips in basics)
Line 7: Line 7:
* Avoid <tt>!important</tt> but if you have to use it, make sure it's obvious why you're using it (maybe with a comment)
* Avoid <tt>!important</tt> but if you have to use it, make sure it's obvious why you're using it (maybe with a comment)
* Avoid magic numbers, prefer automatic sizing
* Avoid magic numbers, prefer automatic sizing
* Avoid platforms specific styles, put everything in the <tt>shared</tt> directory
* Avoid preprocessor variables, use CSS variables instead
* Avoid setting styles in JavaScript. It's generally better to set a class and then specify the styles in CSS
* Avoid setting styles in JavaScript. It's generally better to set a class and then specify the styles in CSS
* <tt>classList</tt> is generally better than <tt>className</tt>. There's less chance of over-writing an existing class
* <tt>classList</tt> is generally better than <tt>className</tt>. There's less chance of over-writing an existing class
Confirmed users
42

edits