Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSS Isn't Sccary

Fen Slattery
June 26, 2017
210

CSS Isn't Sccary

"CSS Isn't Scary: How to Stop Worrying and Love Front End" is aimed at programmers who've written enough CSS to feel frustrated and is intended to help developers feel more comfortable with CSS. This talk was delivered at Chicago Coder Conference 2017 to an audience of mixed skill levels and knowledge of CSS.

Fen Slattery

June 26, 2017
Tweet

Transcript

  1. CSS ISN'T SCARY: HOW TO STOP WORRYING AND LOVE FRONT

    END with Stephanie Slattery CSS Isn't Scary | @sublimemarch
  2. 1. Why CSS is scary 2. Why CSS is great!

    3. How to write better CSS CSS Isn't Scary | @sublimemarch
  3. 1. Why CSS is scary 2. Why CSS is great!

    3. How to write better CSS CSS Isn't Scary | @sublimemarch
  4. 1. Why CSS is scary 2. Why CSS is great!

    3. How to write better CSS CSS Isn't Scary | @sublimemarch
  5. 1. Why CSS is scary 2. Why CSS is great!

    3. How to write better CSS CSS Isn't Scary | @sublimemarch
  6. UNDERSTAND SPECIFICITY 0. Inline styles 1. IDs 2. Classes, attributes,

    and pseudo-classes 3. Elements and pseudo-elements CSS Isn't Scary | @sublimemarch
  7. USE A SINGLE CLASS AS YOUR SELECTOR .hero-text-link { font-size:

    18px; } INSTEAD OF SOMETHING MORE COMPLEX .hero p a { font-size: 18px; } CSS Isn't Scary | @sublimemarch
  8. <h2 class="fun-title pink-title">Hello</h2> .fun-title { font-family: "Comic Sans", sans-serif; }

    .pink-title { font-family: "Comic Sans", sans-serif; color: pink; } CSS Isn't Scary | @sublimemarch
  9. INSTEAD <h2 class="fun-title pink-title">Hello</h2> .fun-title, .pink-title { font-family: "Comic Sans",

    sans-serif; } .pink-title { color: pink; } CSS Isn't Scary | @sublimemarch
  10. OR EVEN BETTER <h2 class="title pink-title">Hello</h2> .title { font-family: "Comic

    Sans", sans-serif; } .pink-title { color: pink; } CSS Isn't Scary | @sublimemarch
  11. <h2 class="pink-title">Hello!</h2> .title { font-family: "Comic Sans", sans-serif; } .pink-title

    { @extend .title; color: pink; } CSS Isn't Scary | @sublimemarch
  12. PUT IT IN A HACKS.CSS FILE IF YOU'RE ▸ using

    magic numbers ▸ writing overly specific selectors ▸ using !important flags ▸ undoing styles that are elsewhere in the code CSS Isn't Scary | @sublimemarch
  13. AND SO MUCH MORE! - learn the box model -

    use flexbox - pick a preprocessor - implement a naming methodology like BEM or OOCSS - try visual diffs to test your code - use a linter - look at dev tools - use a CSS reset CSS Isn't Scary | @sublimemarch