Over time we all learn little nifty coding tricks that help us solve common problems or anticipate potential bugs. What's your favorite CSS or JavaScript tip for beginners and professionals? What do you keep using often in your design or development work?
Ask HN: What's your most useful CSS or JavaScript trick?
1–7 of 7 posts
Re: Ask HN: What's your most useful CSS or JavaScript trick?
#2CSS Reset. Every project starts with a full reset.
Re: Ask HN: What's your most useful CSS or JavaScript trick?
#3document.styleSheets[0].insertRule(...)
Re: Ask HN: What's your most useful CSS or JavaScript trick?
#4*rule/_rule for CSS ie6/7 hacks
font-weight: 900 instead of bold, saves 1 character :P
Re: Ask HN: What's your most useful CSS or JavaScript trick?
#5Simple doctype:
Script tags just work (no need for type="text/javascript":
CSS
Understand how to do general vs specific border/margin/etc assignments and how they cascade. Useful for generic
classes:
.class1{ border:1px solid #000; }
.sub_class1{ border-bottom:2px solid #cc0000; }
JS
0|3.14 === 3, vs Math.floor(3.14) === 3
Re: Ask HN: What's your most useful CSS or JavaScript trick?
#6CSS Reset. Every project starts with a full reset.
Full Reset? As in * { clear everything }?