Is CSS a Programming Language?

A presentation at Abstractions II in August 2019 in Pittsburgh, PA, USA by Lara Schenck

Slide 1

Slide 1

Slide 2

Slide 2

Slide 3

Slide 3

Slide 4

Slide 4

Slide 5

Slide 5

Slide 6

Slide 6

Slide 7

Slide 7

Slide 8

Slide 8

Slide 9

Slide 9

Slide 10

Slide 10

What is A Programming Language? By Will Chrichton

Slide 11

Slide 11

Slide 12

Slide 12

Slide 13

Slide 13

Slide 14

Slide 14

Slide 15

Slide 15

Slide 16

Slide 16

Link to the Tweet.

Slide 17

Slide 17

Slide 18

Slide 18

Slide 19

Slide 19

Slide 20

Slide 20

Slide 21

Slide 21

Slide 22

Slide 22

Slide 23

Slide 23

Slide 24

Slide 24

Slide 25

Slide 25

Slide 26

Slide 26

Slide 27

Slide 27

Slide 28

Slide 28

Slide 29

Slide 29

Slide 30

Slide 30

Slide 31

Slide 31

Slide 32

Slide 32

Slide 33

Slide 33

Slide 34

Slide 34

Slide 35

Slide 35

Slide 36

Slide 36

Slide 37

Slide 37

Slide 38

Slide 38

Slide 39

Slide 39

Slide 40

Slide 40

Slide 41

Slide 41

Slide 42

Slide 42

Slide 43

Slide 43

Slide 44

Slide 44

Slide 45

Slide 45

Slide 46

Slide 46

Slide 47

Slide 47

Slide 48

Slide 48

Slide 49

Slide 49

Slide 50

Slide 50

Slide 51

Slide 51

Slide 52

Slide 52

Wikipedia

Slide 53

Slide 53

Slide 54

Slide 54

Slide 55

Slide 55

WolframMathWorld

Slide 56

Slide 56

WolframMathWorld

Slide 57

Slide 57

WolframMathWorld

Slide 58

Slide 58

WolframMathWorld

Slide 59

Slide 59

if ( cellOne == 1 && cellTwo == 0 && cellThree == 0 ) { cellFour = 1; } input:checked + input:not(:checked) + input:not(:checked) + * { /* Style fourth cell to prompt human to change state */ }

Slide 60

Slide 60

Rule 110 in CSS/HTML/Human

Slide 61

Slide 61

Slide 62

Slide 62

Accidentally Turing Complete by Andreas Zwinkau

Slide 63

Slide 63

Slide 64

Slide 64

Slide 65

Slide 65

Slide 66

Slide 66

Slide 67

Slide 67

Slide 68

Slide 68

Slide 69

Slide 69

Slide 70

Slide 70

Slide 71

Slide 71

Slide 72

Slide 72

.square { width: 100px; height: 100px; background-color: blue; }

<div class=”square”></div>

Slide 73

Slide 73

.square { width: 100px; height: 100px; background-color: blue; } .square—bigger { width: 150px; height: 150px; } .square—smaller { width: 50px; height: 50px; }

<div class=”square”></div> <div class=”square square—bigger”></div> <div class=”square square—smaller”></div>

Slide 74

Slide 74

.square { width: 100px; height: 100px; background-color: blue; }

<div class=”square”></div>

Slide 75

Slide 75

.square { —square-size: 100px; width: var( —square-size ); height: var( —square-size ); background-color: blue; }

<div class=”box”></div> class=”square”></div>

Slide 76

Slide 76

.square { —square-size: 100px; width: var( —square-size ); height: var( —square-size ); background-color: blue; } .square—bigger { —square-size: 150px; } .square—smaller { —square-size: 50px; }

<div class=”square”></div> <div class=”square square—bigger”></div> <div class=”square square—smaller”></div>

Slide 77

Slide 77

Slide 78

Slide 78

.square { … } .square—bigger { —square-size: 150px; } .square—smaller { —square-size: 50px; } .square—rounded { border-radius: 50%; }

<div class=”square”></div> <div class=”square square—bigger”></div> <div class=”square square—smaller”></div> <div class=”square square—smaller square—rounded”></div>

Slide 79

Slide 79

Slide 80

Slide 80

.square { … } .square—bigger { —square-size: 150px; } .square—rounded { border-radius: 50%; } .square—yellow { background-color: yellow; }

<div class=”square”></div> <div class=”square square—rounded square—bigger square—yellow”></div>

Slide 81

Slide 81

.square { —square-size: 100px; —square-bg-color: blue; …

<div class=”square”></div> <div class=”square square—rounded square—yellow”></div> background-color: var( —square-bg-color ); } .square—bigger { … } .square—rounded { … } .square—yellow { —square-bg-color: yellow; }

Slide 82

Slide 82

Slide 83

Slide 83

.square { —square-size: 100px; —square-bg-color: blue;

<div class=”square”></div> width: var( —square-size ); height: var( —square-size ); background-color: var( —square-bg-color ); }

Slide 84

Slide 84

.shape { —shape-height: 100px; —shape-width: 100px; —shape-bg-color: blue;

<div class=”shape”></div> width: var( —shape-width ); height: var( —shape-height ); background-color: var( —shape-bg-color ); }

Slide 85

Slide 85

.shape { … } .shape—bigger { —shape-height: 150px; —shape-width: 150px; } .shape—smaller { —shape-height: 50px; —shape-width: 50px; } .shape—yellow { … } .shape—rounded { … }

<div class=”shape”></div> <div class=”shape shape—bigger”></div> <div class=”shape shape—smaller”></div> <div class=”shape shape—rounded shape—bigger shape—yellow”></div>

Slide 86

Slide 86

.shape { … } .shape—big-square { —shape-height: 150px; —shape-width: 150px; } .shape—small-square { —shape-height: 50px; —shape-width: 50px; } .shape—yellow { … } .shape—rounded { … }

<div class=”shape”></div> <div class=”shape shape—big-square”></div> <div class=”shape shape—small-square”></div <div class=”shape shape—rounded shape—big-square shape—yellow”></div>

Slide 87

Slide 87

.shape { … } .shape—big-square { … } .shape—small-square { … } .shape—yellow { … } .shape—rounded { … } .shape—rectangle { —shape-height: 50px; —shape-width: 100px; }

<div class=”shape”></div> <div class=”shape shape—big-square”></div> <div class=”shape shape—small-square”></div <div class=”shape shape—rounded shape—big-square shape—yellow”></div> <div class=”shape shape—rectangle”></div>

Slide 88

Slide 88

.shape { … } .shape—big-square { … } .shape—small-square { … } .shape—yellow { … } .shape—rounded { border-radius: 50%; } .shape—rectangle { … }

<div class=”shape”></div> <div class=”shape shape—big-square”></div> <div class=”shape shape—small-square”></div <div class=”shape shape—rounded shape—big-square shape—yellow”></div> <div class=”shape shape—rectangle”></div>

Slide 89

Slide 89

.shape { … } .shape—big-square { … } .shape—small-square { … } .shape—yellow { … } .shape—circle { border-radius: 50%; } .shape—rounded { border-radius: 20px; } .shape—rectangle { … }

<div class=”shape”></div> <div class=”shape shape—big-square”></div> <div class=”shape shape—small-square”></div <div class=”shape shape—circle shape—big-square shape—yellow”></div> <div class=”shape shape—rectangle shape—rounded”></div>

Slide 90

Slide 90

Sign Up For Our Newsletter

Slide 91

Slide 91

.shape { … } .shape__text { color: white; font-size: 16px; } .shape—big-square { … } .shape—small-square { … } .shape—yellow { … } .shape—rounded { … } .shape—circle { … } .shape—has-text { —shape-height: initial; —shape-width: initial; }

<div class=”shape”></div> <div class=”shape shape—big-square”></div> <div class=”shape shape—small-square”></div <div class=”shape shape—circle shape—big-square shape—yellow”></div> <div class=”shape shape—rounded-rectangle”></div> <button class=”shape shape—has-text”> <a href=”” class=”shape__text”></a> </button>

Slide 92

Slide 92

Sign Up For Our Newsletter 📝 Sign Up For Our Newsletter

Slide 93

Slide 93

.shape { … } .shape__text { color: white; font-size: 16px; } .shape—big-square { … } .shape—small-square { … } .shape—rounded-rectangle { … } .shape—yellow { … } .shape—circle { … } .shape—has-text { —shape-height: initial; —shape-width: initial; }

<div class=”shape”></div> <div class=”shape shape—big-square”></div> <div class=”shape shape—small-square”></div <div class=”shape shape—circle shape—big-square shape—yellow”></div> <div class=”shape shape—rounded-rectangle”></div> <button class=”shape shape—has-text”> <a href=”” class=”shape__text”></a> </button>

Slide 94

Slide 94

Slide 95

Slide 95

Slide 96

Slide 96

Slide 97

Slide 97

Slide 98

Slide 98

Slide 99

Slide 99

Robert C. Martin in The Future of Programming

Slide 100

Slide 100

Slide 101

Slide 101

Slide 102

Slide 102

Slide 103

Slide 103

.square { width: 100px; height: 100px; background-color: blue; }

<div class=”square”></div>

Slide 104

Slide 104

.shape { —shape-height: 100px; —shape-width: 100px; —shape-bg-color: blue;

<div class=”shape”></div> width: var( —shape-width ); height: var( —shape-height ); background-color: var( —shape-bg-color ); }

Slide 105

Slide 105

Slide 106

Slide 106

Slide 107

Slide 107

Slide 108

Slide 108

Slide 109

Slide 109

Slide 110

Slide 110

Slide 111

Slide 111

Slide 112

Slide 112

Slide 113

Slide 113

Slide 114

Slide 114

Slide 115

Slide 115

Slide 116

Slide 116

Slide 117

Slide 117

Slide 118

Slide 118

Slide 119

Slide 119

Slide 120

Slide 120

Slide 121

Slide 121

Slide 122

Slide 122

function sort(array) { for (let i = 0; i < array.length; i++) { for (let ii = 0; ii < array.length; ii++) { if (array[ii] > array[ii+1]) { let temp = array[ii]; array[ii] = array[ii+1]; array[ii+1] = temp; } } } return array; } var sorted = sort([4, 2, 1, 3]);

Slide 123

Slide 123

function sort(array) { for (let i = 0; i < array.length; i++) { for (let ii = 0; ii < array.length; ii++) { if (array[ii] > array[ii+1]) { let temp = array[ii]; array[ii] = array[ii+1]; array[ii+1] = temp; } } } return array; } var sorted = sort([4, 2, 1, 3]);

Slide 124

Slide 124

Slide 125

Slide 125

Slide 126

Slide 126

.container { display: flex; }

Slide 127

Slide 127

.container { display: flex; flex-wrap: wrap; }

Slide 128

Slide 128

// Flex in Servo // https://github.com/servo/servo/blob/master/components/layout/flex.rs fn get_flex_line(&mut self, container_size: Au) -> Option<FlexLine> { … for item in items { let kid = children.get(item.index); item.init_sizes(kid, container_size, self.main_mode); let outer_main_size = item.outer_main_size(kid, self.main_mode); if total_line_size + outer_main_size > container_size && end != start && self.is_wrappable { break; } } … }

Slide 129

Slide 129

Slide 130

Slide 130

Slide 131

Slide 131

.container { display: flex; flex-wrap: wrap; }

Slide 132

Slide 132

Slide 133

Slide 133

Slide 134

Slide 134

Slide 135

Slide 135

Slide 136

Slide 136

Slide 137

Slide 137

Slide 138

Slide 138

Slide 139

Slide 139

.clearfix::before, .clearfix::after { content: “”; display: table; } .clearfix::after { clear: both; }

Slide 140

Slide 140

.relative-parent { position: relative; } .child-stuck-to-bottom-right-of-closest-relative-parent { position: absolute; right: 0; bottom: 0; }

Slide 141

Slide 141

.spaced-content > * + * { margin-top: 1rem; }

Slide 142

Slide 142

h1 { font-size: calc( 2rem + 3vw ); } // Stops growing at 800px @media( min-width: 800px ) { h1 { font-size: calc( 2rem + ( 800px * } } ( 3 / 100 ) ) );

Slide 143

Slide 143

.grid { display: grid; grid-template-columns: repeat( var( —grid-cols, 1 ), 1fr ); } .grid-cols3 { —grid-cols: 3; } .grid-cols4 { —grid-cols: 4; } .grid-item-span2 { grid-column: span 2; }

Slide 144

Slide 144

Slide 145

Slide 145

Slide 146

Slide 146

Slide 147

Slide 147

Slide 148

Slide 148

Slide 149

Slide 149

Slide 150

Slide 150

Slide 151

Slide 151

Slide 152

Slide 152

Slide 153

Slide 153

Slide 154

Slide 154

Slide 155

Slide 155

Slide 156

Slide 156

Slide 157

Slide 157

Slide 158

Slide 158

.relative-parent { position: relative; } .child-stuck-to-bottom… { position: absolute; right: 0; bottom: 0; } .pmc-a-glue-parent { position: relative; } .pmc-a-glue { // Fallback is top left for IE11. top: 0; left: 0; position: absolute; z-index: $z-index-middle-bottom; top: var( —a-glue-top, initial ); bottom: var( —a-glue-bottom, initial ); right: var( —a-glue-right, initial ); left: var( —a-glue-left, initial ); } .pmc-a-glue—r-0 { —a-glue-right: 0; }

Slide 159

Slide 159

Slide 160

Slide 160

.pmc-a-space-children-horizontal > * + * { margin-left: $spacer-050; // Fallback. margin-left: var( —a-space-children-spacer ); } @supports( column-gap: 1rem ) { .space-content > * + * { margin-top: 1rem; } .pmc-a-space-children-horizontal { column-gap: var( —a-space-children-spacer ); } .pmc-a-space-children-horizontal > * { margin-left: unset; } }

Slide 161

Slide 161

Slide 162

Slide 162

Slide 163

Slide 163

.a-story-arc-item-border-decoration { —a-story-arc-item-border-decoration-dot-offset: 1rem; —a-story-arc-item-border-decoration-before-transform: translate(-50%, 50% ); &::before { content: ”; position: absolute; top: 0; left: 0; transform: var( —a-story-arc-item-border-decoration-before-transform ); width: rem(10); height: rem(10); background-color: map-get( $semantic-color-list, brand-red ); border-radius: 50%; box-shadow: 0px 0px 0px 3px map-get( $semantic-color-list, brand-red-light 0px 0px 0px 6px map-get( $semantic-color-list, brand-red-lightest );

Slide 164

Slide 164

Slide 165

Slide 165

Slide 166

Slide 166

Slide 167

Slide 167

Slide 168

Slide 168

Slide 169

Slide 169

Slide 170

Slide 170

Slide 171

Slide 171

Slide 172

Slide 172

Slide 173

Slide 173

Slide 174

Slide 174

Slide 175

Slide 175

Slide 176

Slide 176

Slide 177

Slide 177

Slide 178

Slide 178

Slide 179

Slide 179

Slide 180

Slide 180

Slide 181

Slide 181

Slide 182

Slide 182

Slide 183

Slide 183

Slide 184

Slide 184

Slide 185

Slide 185

Slide 186

Slide 186

Slide 187

Slide 187

Slide 188

Slide 188

Slide 189

Slide 189

div { counter-reset: fizzbuzz; counter-increment: fizzbuzz; } div::before { content: counter(fizzbuzz); } div:nth-child(3n)::before { content: ‘Fizz’; } div:nth-child(5n)::after { content: ‘Buzz’; } Full FizzBuzz in CSS/HTML CodePen

Slide 190

Slide 190

Slide 191

Slide 191

Slide 192

Slide 192

Slide 193

Slide 193

Slide 194

Slide 194

Slide 195

Slide 195

Slide 196

Slide 196

Slide 197

Slide 197

Slide 198

Slide 198

Slide 199

Slide 199

Slide 200

Slide 200

Slide 201

Slide 201

Slide 202

Slide 202

Slide 203

Slide 203

Slide 204

Slide 204

Slide 205

Slide 205

Slide 206

Slide 206

Slide 207

Slide 207

Slide 208

Slide 208

Slide 209

Slide 209

Slide 210

Slide 210

Slide 211

Slide 211

Slide 212

Slide 212