Skip to main content

Posts

Showing posts from August, 2015

The 30 CSS Selectors you Must Memorize

The 30 CSS Selectors you Must Memorize So you learned the base id , class , and descendant selectors - and then called it a day? If so, you're missing out on an enormous level of flexibility. While many of the selectors mentioned in this article are part of the CSS3 spec, and are, consequently, only available in modern browsers, you owe it to yourself to commit these to memory. 1. * 1 2 3 4 * {   margin : 0 ;   padding : 0 ; } Let's knock the obvious ones out, for the beginners, before we move onto the more advanced selectors. The star symbol will target every single element on the page. Many developers will use this trick to zero out the margin s and padding . While this is certainly fine for quick tests, I'd advise you to never use this in production code. It adds too much weight on the browser, and is unnecessary. The * can also be used with child selectors. 1 2 3 #container * {   border : 1px solid black ;