Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Breaking Good Habits Harry Roberts—@csswizardry

Slide 3

Slide 3 text

Harry who?! •Web designer/developer •Senior UI Developer—BSkyB •@csswizardry •csswizardry.com

Slide 4

Slide 4 text

Necessary explanation of the cheesy, overly- cryptic talk title.

Slide 5

Slide 5 text

Web standards… •A great idea? Definitely! •Well intentioned? You bet! •Ambiguous? Sadly :( •Open to interpretation? Unfortunately…

Slide 6

Slide 6 text

…web standards •Rules? Definitely not!

Slide 7

Slide 7 text

Best practices •Best for who? •What are we achieving? •What do we really want to achieve? •Are we always solving the right problems for the right people?

Slide 8

Slide 8 text

Good habits? •Avoiding classes and IDs •‘Handcrafting’ our CSS •Avoiding extra markup

Slide 9

Slide 9 text

Bad habits? •Classitis—using too many classes •Grid systems •Extra markup •‘Insemantic’ class names

Slide 10

Slide 10 text

We’ve been solving the wrong problems for the wrong people!

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

The 4 ‘-ility’s •Maintainability •Flexibility •Extensibility •Predictability

Slide 13

Slide 13 text

Maintainability

Slide 14

Slide 14 text

Flexibility

Slide 15

Slide 15 text

body > div:nth-of-type(2) > article:first- child > p:first-child{ font-size:1.2em }

Lorem ipsum dolor sit amet...

Slide 16

Slide 16 text

Be ?#*@ing explicit!

Slide 17

Slide 17 text

.intro{ font-size:1.2em; }

Lorem ipsum dolor sit amet...

Slide 18

Slide 18 text

Specific !== explicit

Slide 19

Slide 19 text

Extensibility

Slide 20

Slide 20 text

Extensible •Stop thinking in pages… •…think in components… •…then think in abstractions.

Slide 21

Slide 21 text

Predictability

Slide 22

Slide 22 text

Expect the unexpected Always build like your client’s CMS is a bulldozer…

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

CSS selectors

Slide 25

Slide 25 text

IDs •Don’t use IDs in CSS •Ever.

Slide 26

Slide 26 text

IDs •No advantage over classes. •Waaaaaay overly specific. •Not dissimilar to !important •Everything you can do with an ID can be done with a class.

Slide 27

Slide 27 text

Classes •No one uses classes except browsers and other developers (and microformats). •Classes are neither semantic or insemantic; they’re sensible or insensible.

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

.red .red{ color:red; }

I am a designer and developer

Slide 30

Slide 30 text

.red .red{ color:blue; /* WTF */ }

I am a designer and developer

Slide 31

Slide 31 text

.brand .brand{ color:#BADA55; /* FTW */ }

I am a designer and developer

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Objects and abstractions

Slide 34

Slide 34 text

The media object bit.ly/cCY3Ew

Slide 35

Slide 35 text

The media object bit.ly/cCY3Ew

Slide 36

Slide 36 text

The media object bit.ly/cCY3Ew

Slide 37

Slide 37 text

The media object bit.ly/cCY3Ew

Slide 38

Slide 38 text

The media object bit.ly/cCY3Ew

Lorem ipsum...

.media,.body { overflow:hidden; } .img { float:left; margin-right:20px; } .img img { display:block; }

Slide 39

Slide 39 text

The media object bit.ly/cCY3Ew

Lorem ipsum...

Read more...

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Nicole Sullivan @stubbornella

Slide 42

Slide 42 text

The nav abstraction bit.ly/oD2M9n

Slide 43

Slide 43 text

.nav{ list-style:none; margin-left:0; } .nav li{ display:inline; } .nav a{ display:inline-block; } The nav abstraction bit.ly/oD2M9n

Slide 44

Slide 44 text

.breadcrumb li:before{ content:"» "; } .breadcrumb li:first-child:before{ content:""; } Breadcrumbs…? bit.ly/oD2M9n

Slide 45

Slide 45 text

The island object bit.ly/oqQ7JJ

Slide 46

Slide 46 text

The island object bit.ly/oqQ7JJ
...
.island{ padding:1.5em; } .island > :last-child{ margin-bottom:0; }

Slide 47

Slide 47 text

The island object bit.ly/oqQ7JJ
...
.island.promo{ color:#fff; background-color:#C0FFEE; }

Slide 48

Slide 48 text

Double stranded heading hierarchy h1,.alpha { font-size:; line-height:; } h2,.beta { font-size:; line-height:; } h3,.gamma { font-size:; line-height:; } h4,.delta { font-size:; line-height:; } h5,.epsilon { font-size:; line-height:; } h6,.zeta { font-size:; line-height:; }

Slide 49

Slide 49 text

Double stranded heading hierarchy

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

Grid systems

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

Abstract layout into its own layer Keep components free of dimensions

Slide 54

Slide 54 text

csswizardry.com/fluid-grids

Slide 55

Slide 55 text

Straighten up! @media(max-width:480px){ .grid{ float:none; clear:both; width:auto; margin:0; } }

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

All together now!

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

Benefits and side- effects •Sites are faster to build… •…more robust •…more maintainable •…more consistent •…and incidentally more efficient.

Slide 69

Slide 69 text

Efficiency on the client side •Reused classes are ‘performance freebies’ •Abstractions mean DRYer code; less to download and evaluate •Classes match quicker than descendants

Slide 70

Slide 70 text

Now what? •Solve problems for the right people. •Keep yourselves happy and sane. •Learn when enough is enough; cut yourself some slack.

Slide 71

Slide 71 text

However bad you think it is, there’s always worse…

Slide 72

Slide 72 text

Breaking Good Habits •Harry Roberts – @csswizardry •csswizardry.com •Nicole Sullivan – @stubbornella