Joined June 2011
·
Posted to
Some things are !important;
over 1 year
ago
Most things are not !important.
Recommended reading: http://coding.smashingmagazine.com/2010/11/02/the-important-css-declaration-how-and-when-to-use-it/
In general, I try to minimize !important
use to general states only, e.g. .hidden
which should override normal rules.
Posted to
DO NOT $('#foo a'); DO $('#foo').find('a');
over 1 year
ago
The difference in actual runtime performance here is so tiny, I doubt if it matters in any real-world use case (who on earth matches millions of selectors, not to mention in a loop over time?).
Just use what's more readable and makes sense in your context. If you nailed the big stuff, tweaked the medium issues and ran out of micro-optimizations, come back to this tip.
Achievements
49 Karma
9,816 Total ProTip Views
![](https://dj1symwmxvldi.cloudfront.net/assets/badges/forked1-63f23ad054823f6065b4526f8552dbc2c4fbaa75d22db7150d700201218ac426.png)
Forked
Have a project valued enough to be forked by someone else
![](https://dj1symwmxvldi.cloudfront.net/assets/badges/cub-d811dfda174e9ca232964477c16369e9ed8caf4a47d746348a358f3579b8ffdc.png)
Cub
Have at least one original jQuery or Prototype open source repo
![](https://dj1symwmxvldi.cloudfront.net/assets/badges/charity-bab6d575c53894cc9e395db7cdb1f0f91f176fa0cc8122c5f824e672f3d556a4.png)
Charity
Fork and commit to someone's open source project in need
Nice. What about vertical alignment? Adding simliar
top
properties doesn't seem to work.