Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Stop using JS for that Moving features from JS to CSS & HTML 🙈 Hoo boy.

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

I'm Kilian Valkhof Kilianvalkhof.com | @kilianvalkhof

Slide 5

Slide 5 text

I'm Kilian Valkhof Kilianvalkhof.com | @kilianvalkhof 👴Spent the past 20 years building websites

Slide 6

Slide 6 text

I'm Kilian Valkhof Kilianvalkhof.com | @kilianvalkhof 👴Spent the past 20 years building websites 🌐Make a browser for devs called Polypane

Slide 7

Slide 7 text

I'm Kilian Valkhof Kilianvalkhof.com | @kilianvalkhof 👴Spent the past 20 years building websites 🌐Make a browser for devs called Polypane 🔘Part of the Electron governance team

Slide 8

Slide 8 text

I ❤️ JS

Slide 9

Slide 9 text

I ❤️ CSS

Slide 10

Slide 10 text

I ❤️

Slide 11

Slide 11 text

The rule of least power

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Choose the least powerful language suitable for a given purpose

Slide 14

Slide 14 text

Browser makers are listening And are implementing the stuff we built by hand

Slide 15

Slide 15 text

Lets get started

Slide 16

Slide 16 text

Custom toggles

Slide 17

Slide 17 text

My awesome feature My awesome feature

Slide 18

Slide 18 text

My awesome feature input { appearance: none; position:relative; display:inline-block; background:lightgrey; height:1.65rem; width:2.75rem; vertical-align:middle; border-radius:2rem; box-shadow:0px 1px 3px #0003 inset; transition: 0.25s linear background; } input::before { content: ''; display:block; width:1.25rem; height:1.25rem; background: #fff; border-radius:1.2rem; position: absolute; top:0.2rem; left:0.2rem; box-shadow:0px 1px 3px #0003; transition: 0.25s linear transform; transform:translateX(0rem); }

Slide 19

Slide 19 text

My awesome feature :checked { background:green; } :checked::before { transform:translateX(1rem) }

Slide 20

Slide 20 text

My awesome feature polypane.app/forced-colors input:focus { /* no: */ outline: none; /* yes: */ outline-color: transparent; } input:focus-visible { outline:2px solid dodgerblue; outline-offset: 2px }

Slide 21

Slide 21 text

My awesome feature Try it: codepen.io/Kilian/pen/YzYLprM

Slide 22

Slide 22 text

Datalist

Slide 23

Slide 23 text

Bootstrap Tailwind CSS Foundation Bulma Skeleton codepen.io/Kilian/pen/vYpjgoZ

Slide 24

Slide 24 text

input { color-scheme: dark; }

Slide 25

Slide 25 text

Complex page transitions

Slide 26

Slide 26 text

jQuery. Awesome. $('a[href*="#"]') .click(function() { var target = $(this.hash); $('html').animate({ scrollTop: target.offset().top }, 1000) });

Slide 27

Slide 27 text

html { scroll-behavior: smooth; } To bottom Forage distillery enim yuccie pop-up fixie, raclette adipisicing cillum hammock cupidatat PBR&B incididunt. Man bun neutra austin est listicle, slow-carb twee incididunt brunch hexagon. Stumptown ennui banjo wolf salvia aesthetic pabst health goth tempor heirloom lorem aliquip next level street art. Flannel pour-over 3 wolf moon venmo letterpress, next level adipisicing. Dreamcatcher craft beer narwhal lomo chicharrones cupidatat four loko, meggings dolore roof party. Hella asymmetrical man bun austin meh woke vice sriracha aliqua consequat excepteur in pug keffiyeh. Sartorial tote bag leggings wolf art party humblebrag est brunch. Scenester asymmetrical quis helvetica non pok pok bespoke aute waistcoat deserunt id nulla actually semiotics pork belly. Marfa sriracha commodo edison bulb dolore la croix XOXO sed duis. Copper mug pour-over +1 cray dolore squid sriracha officia. Everyday carry green juice iceland enim. Pork belly kombucha anim slow-carb lomo vape consequat mumblecore. Seitan austin raw denim, laboris tumeric 8-bit marfa lo-fi. Art party meh adaptogen vice master cleanse duis mumblecore typewriter DIY fingerstache unicorn. Proident commodo pitchfork fugiat art party austin. Hexagon lorem hot chicken umami, authentic butcher pinterest ex food truck cardigan kale chips. Bitters narwhal 3 wolf moon, helvetica pickled flannel neutra disrupt lomo consequat lyft. Cupidatat chartreuse meditation +1 occupy shabby chic deserunt glossier plaid. Cloud bread dolor hoodie chillwave, proident live-edge enim ut pickled synth +1 unicorn hell of. Culpa taiyaki bushwick waistcoat hexagon cardigan meditation. Disrupt shaman ethical palo santo, crucifix synth post-ironic roof party cred hell of butcher. Meggings enim minim kombucha, artisan schlitz lumbersexual veniam PBR&B

Slide 28

Slide 28 text

In JavaScript behavior: "smooth" window.scrollTo({ 1 top:1000, 2 3 }); 4

Slide 29

Slide 29 text

Accessibility @media ( prefers-reduced-motion: no-preference ) { html { scroll-behavior: smooth; } }

Slide 30

Slide 30 text

Smooth

Slide 31

Slide 31 text

#my-target { scroll-margin-top: 100px; } To target Forage distillery enim yuccie pop-up fixie, raclette adipisicing cillum hammock cupidatat PBR&B incididunt. Man bun neutra austin est listicle, slow-carb twee incididunt brunch hexagon. Stumptown ennui banjo wolf salvia aesthetic pabst health goth tempor heirloom lorem aliquip next level street art. Flannel pour-over 3 wolf moon venmo letterpress, next level adipisicing. Dreamcatcher craft beer narwhal lomo chicharrones cupidatat four loko, meggings dolore roof party. Hella asymmetrical man bun austin meh woke vice sriracha aliqua consequat excepteur in pug keffiyeh. Sartorial tote bag leggings wolf art party humblebrag est brunch. Scenester asymmetrical quis helvetica non pok pok bespoke aute waistcoat deserunt id nulla actually semiotics pork belly. Marfa sriracha commodo edison bulb dolore la croix XOXO sed duis. Copper mug pour-over +1 cray dolore squid sriracha officia. Everyday carry green juice iceland enim. Pork belly kombucha anim slow-carb lomo vape consequat mumblecore. Seitan austin raw denim, laboris tumeric 8-bit marfa lo-fi. Art party meh adaptogen vice master cleanse duis mumblecore typewriter DIY fingerstache unicorn. Proident commodo pitchfork fugiat art party austin. Hexagon lorem hot chicken umami, authentic butcher pinterest ex food truck cardigan kale chips. My middle title to top Bitters narwhal 3 wolf moon, helvetica pickled flannel neutra disrupt lomo consequat lyft. Cupidatat chartreuse Header

Slide 32

Slide 32 text

#my-target:target { outline: 10px solid deeppink; transition: 1s ease-in-out outline; } To target Forage distillery enim yuccie pop-up fixie, raclette adipisicing cillum hammock cupidatat PBR&B incididunt. Man bun neutra austin est listicle, slow-carb twee incididunt brunch hexagon. Stumptown ennui banjo wolf salvia aesthetic pabst health goth tempor heirloom lorem aliquip next level street art. Flannel pour-over 3 wolf moon venmo letterpress, next level adipisicing. Dreamcatcher craft beer narwhal lomo chicharrones cupidatat four loko, meggings dolore roof party. Hella asymmetrical man bun austin meh woke vice sriracha aliqua consequat excepteur in pug keffiyeh. Sartorial tote bag leggings wolf art party humblebrag est brunch. Scenester asymmetrical quis helvetica non pok pok bespoke aute waistcoat deserunt id nulla actually semiotics pork belly. Marfa sriracha commodo edison bulb dolore la croix XOXO sed duis. Copper mug pour-over +1 cray dolore squid sriracha officia. Everyday carry green juice iceland enim. Pork belly kombucha anim slow-carb lomo vape consequat mumblecore. Seitan austin raw denim, laboris tumeric 8-bit marfa lo-fi. Art party meh adaptogen vice master cleanse duis mumblecore typewriter DIY fingerstache unicorn. Proident commodo pitchfork fugiat art party austin. Hexagon lorem hot chicken umami, authentic butcher pinterest ex food truck cardigan kale chips. My middle title Bitters narwhal 3 wolf moon, helvetica pickled flannel neutra disrupt lomo consequat lyft. Cupidatat chartreuse Header

Slide 33

Slide 33 text

div { position: relative; } div > .sticky { position: sticky; top: 50%; }

Slide 34

Slide 34 text

Carousels 🎠

Slide 35

Slide 35 text

Carousels 🎠 scroll-snap-*

Slide 36

Slide 36 text

1
1
2
...
5
scroll-snap-type: x mandatory; scroll-snap-align: start; .scroller { 1 2 } 3 .scroller div { 4 5 } 6

Slide 37

Slide 37 text

1 2 3 scroll-snap-type: x mandatory; scroll-snap-align: center; .scroller2 { 1 2 } 3 .scroller2 div { 4 5 } 6

Slide 38

Slide 38 text

youtu.be/34zcWFLCDIc

Slide 39

Slide 39 text

Lazy Loading loading="lazy" 5

Slide 40

Slide 40 text

Force downloads download 4 Very important report (pdf) 5 6

Slide 41

Slide 41 text

Accordions and modals

Slide 42

Slide 42 text

Here is my title Here is my title

Here is my paragraph

Slide 43

Slide 43 text

Here is my title Here is my paragraph Here is my title

Here is my paragraph

Slide 44

Slide 44 text

➕Here is my title summary::marker { font-size: 1.5em; content: ' ➕ '; } [open] summary::marker { font-size: 1.5em; content: ' ➖ '; }

Slide 45

Slide 45 text

Here is my title summary:hover { cursor: pointer; background: deeppink; }

Slide 46

Slide 46 text

Slide 47

Slide 47 text

This is a pretty dialog

Close

Slide 48

Slide 48 text

Show modal Show the dialog

Slide 49

Slide 49 text

Show modal

Tabs or spaces?

Tabs Spaces dialog.addEventListener("close", function() { console.log(dialog.returnValue); // "correct" });

Slide 50

Slide 50 text

Show modal dialog::backdrop { background: #fff5; backdrop-filter: blur(4px); }

Slide 51

Slide 51 text

Stop using JS... 🌌in the future 🌌

Slide 52

Slide 52 text

grid-template-rows: masonry; .container { 1 display: grid; 2 grid-template-columns: repeat(4, 1fr); 3 4 } 5 Masonry layout smashingmagazine.com/native-css-masonry-layout-css-grid/

Slide 53

Slide 53 text

Option 1 Option 2 Option 3 Selectmenu Option 1 Option 2 Option 3

Slide 54

Slide 54 text

Option 1 Option 2 Option 3 selectmenu::part(button) { color: white; background-color: #f00; padding: 5px; border-radius: 5px; } selectmenu::part(listbox) { padding: 10px; margin-top: 5px; border: 5px solid red; border-radius: 20px; gap: 10px; width: 240px; font-size: 1rem; } selectmenu option { padding:10px; border-radius:10px; font-weight: bold; }

Slide 55

Slide 55 text

Option 1 Option 2 Option 3 selectmenu::part(listbox) { display: grid; }

Slide 56

Slide 56 text

👴👵 The Parent Selector :has()

Slide 57

Slide 57 text

Which do you use? Bootstrap Chakra Tailwind Materialize Other Which do you use? Bootstrap Chakra Tailwind Materialize Other form #other-text { display: none; } form:has(#other:checked) #other-text { display: block; }

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

https://polypane.app/where-is-has/

Slide 60

Slide 60 text

Scroll linked animations Resources HTML CSS E D I T O N Result 1× 0.5× 0.25× Rerun bram.us/2021/02/23/the-future-of-css-scroll-linked-animations-part-1/

Slide 61

Slide 61 text

No more JS needed! 🥳

Slide 62

Slide 62 text

…I hope you love CSS and HTML now, too! ask me about Polypane @kilianvalkhof | kilianvalkhof.com | polypane.com