SlideShare a Scribd company logo
Chris Heilmann
@codepo8
christianheilmann.com
CSS vs. JavaScript:
Trust vs. Control
CSS vs. JavaScript - Trust vs. Control
https://twitter.com/floatvoid/status/863605150799118336
https://twitter.com/gianablantin/status/860965927898054656
CSS seems to be confusing for programmers…
CSS is fault tolerant – this can be confusing
JavaScript is not fault tolerant – this can be disastrous
CSS
You apply your styles
and you hope it
worked.
JavaScript
You control the styling
and you can and should
verify that it worked
embracethesquishiness.com
Means embracing the
squishiness of the web!
embracethesquishiness.com
Things beyond your
control:
• The browsers of your users
• The resolution, pixel depth and colour settings
of their devices
• Their connection reliability and speed
• Their connection restrictiveness – resources
may be blocked
• Their font size and zoom needs
• The availability of resources on their machines
for your product (is the CPU already burning?)
• The amount of text content and image sizes in
your product – CMS anyone?
CSS
It is the job of the browser
to perform well, use GPU
resources and skip
functionality.
JavaScript
It’s your job to test for
support, to ensure rendering,
painting and reflow is fast and
to keep animation in sync.
So why do we constantly under-estimate CSS and
over-value the benefits of JavaScript?
CSS had a bumpy history…
• Initially very limited and a replacement for
visual HTML and attributes (font, bgcolor,
align…)
• Patchy browser support and very odd errors
without debugging options
• Massive jump in functionality when iPhone
became a thing and Apple called the shots
• Lots of problems with browser wars around
prefixes
• Up until recently no layout model, but hacks
using positioning and floating. So, too
restrictive or too confusing
Our solution was to patch with JavaScript.
We can read out conditions and react to them
creating HTML and applying styling.
But CSS has been going leaps and bounds
• Evergreen browsers are a thing
• Browser tooling gives detailed insights
• Support is well documented: caniuse.com
• Support channels and bug tracking is available
for almost all browsers
• Pre-processors like Sass and Less have turned
up the heat to innovate the spec faster, much
like jQuery inspired JavaScript of today
• Approaches like OOCSS (Nicole Sullivan) and
Atomic Design (Brad Frost) help work with
maintainability across different componentss
So here are some amazing things CSS can do
now and you should consider using…
Calculated CSS values
Calculations
developer.mozilla.org/en/docs/Web/CSS/calc
Calculations
developer.mozilla.org/en/docs/Web/CSS/calc
Calculations
developer.mozilla.org/en/docs/Web/CSS/calc
Media
Queries
Media Queries
developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
Media Queries
developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
Media Queries
developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
Generated
content
Generated Content
a.singlediv.comhttps://developer.mozilla.org/en-US/docs/Web/CSS/::before
Generated Content
http://a.singlediv.com/
Animations
and transitions
Animations / Transitions
developer.mozilla.org/en-US/docs/Web/CSS/CSS_Animations/Using_CSS_animations
developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions
Animations / Transitions
Animations / Transitions
Viewport Units
Viewport Units
Viewport Width (vw)
A percentage of the full viewport width.
f.e. 480px wide screen - 10vw is 10% or 48px
% is percentage of the parent element, vw is
percentage of the window.
Viewport Height (vh)
A percentage of the full viewport height.
Viewport Minimum (vmin)
A percentage of the viewport width or height,
whichever is smaller.
10vmin = 10% of the current viewport width in
portrait and 10% of the viewport height on
landscape.
Viewport Maximum (vmax)
A percentage of the viewport width or height,
whichever is larger.
Viewport Units
css-tricks.com/fun-viewport-units/
Viewport Units
css-tricks.com/fun-viewport-units/
Viewport Units
css-tricks.com/fun-viewport-units/
Flexbox
Flexbox
http://flexbox.buildwithreact.com/
Flexbox
flexboxfroggy.com/
Flexbox
vimeo.com/145055822
Flexbox
CSS Grid
Grid
developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout
Grid
gridbyexample.com
Grid
gridbyexample.com
Grid
cssgridgarden.com
Grid
youtube.com/watch?v=N5Lt1SLqBmQs youtube.com/watch?v=5Z7lSSMwRgo
Grid
Grid and flexbox
Flexbox was designed for layout in
one dimension, layout in a row or a
column.
Grid was designed for two-
dimensional layout, layout in rows
and columns at the same time.
Grid can and should use Flexbox in
its cells.
developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Relationship_of_Grid_Layout
Why is there a
flexbox and a grid?
CSS Custom
properties
(variables)
Custom Properties (variables)
developer.mozilla.org/en-US/docs/Web/CSS/--*
Custom Properties (variables)
youtube.com/watch?v=kZOJCVvyF-4
Custom Properties (variables)
CSS Feature Queries
CSS Feature Queries
https://developer.mozilla.org/en-US/docs/Web/CSS/@supports
CSS Feature Queries
http://a.singlediv.com/
CSS and JavaScript?
CSS and JavaScript working together is incredibly
powerful and the right thing to do.
CSS can’t solve everything…
speakerdeck.com/didoo/let-there-be-peace-on-css
Cristiano Rastelli
@areaweb
CSS and JavaScript working together in a
non-module world…
• Use CSS when you can using the things you
saw here
• If you need to communicate with CSS, consider
changing Custom Properties
• If that’s not an option apply classes to parent
elements using classList.
• As a very last resort, you can alter the style
directly
CSS and JavaScript working together in a
non-module world…
youtube.com/watch?v=kZOJCVvyF-4
CSS and JavaScript working together in a
non-module world…
youtube.com/watch?v=kZOJCVvyF-4
Every style change has consequences…
csstriggers.com
Paul Lewis @aerotwist
Das Surma @DasSurma
CSS is much more
reliable than it used
to be…
Users over authors over implementors over
specifiers over theoretical purity…
https://www.w3.org/TR/html-design-principles/
Our users deserve
interfaces that are
smooth, reliable and
don’t kill their batteries.
So, consider CSS a bit
more…
You can be lazy and build
on the work of the
community…
Super inspiring and highly active CSS folk!
CHRIS HEILMANN
@CODEPO8
CHRISTIANHEILMANN.COM
THANKS!
Ad

Recommended

PDF
Leveling up your JavaScipt - DrupalJam 2017
Christian Heilmann
 
PDF
Breaking out of the Tetris mind set #btconf
Christian Heilmann
 
PDF
Progressive Web Apps – the return of the web?
Christian Heilmann
 
PDF
Progressive Web Apps - Goto Chicago 2017
Christian Heilmann
 
PDF
Turning huge ships - Open Source and Microsoft
Christian Heilmann
 
PDF
Postmodern Web Apps
malteubl
 
PDF
Progressive web and the problem of JavaScript
Christian Heilmann
 
PDF
JavaScript is a buffet - Scriptconf 2017 keynote
Christian Heilmann
 
PDF
Progressive Web Apps - Bringing the web front and center
Christian Heilmann
 
PPTX
That's crazy! how to build single page web apps
Chris Love
 
PDF
Web Development for UX Designers
Ashlimarie
 
PPTX
2021 Chrome Dev Summit: Web Performance 101
Tammy Everts
 
PDF
[jqconatx] Adaptive Images for Responsive Web Design
Christopher Schmitt
 
PDF
The Progressive Web and its New Challenges - Confoo Montréal 2017
Christian Heilmann
 
PPTX
Make JavaScript Faster
Steve Souders
 
PPTX
Doing Modern Web, aka JavaScript and HTML5 in the Enterprise
Chris Love
 
PDF
Stapling and patching the web of now - ForwardJS3, San Francisco
Christian Heilmann
 
PDF
Progressive Web Apps – the return of the web? Goto Berlin 2016
Christian Heilmann
 
PDF
A New Hope – the web strikes back
Christian Heilmann
 
PDF
Dreamweaver CS6, jQuery, PhoneGap, mobile design
Dee Sadler
 
PDF
The Soul in The Machine - Developing for Humans (FrankenJS edition)
Christian Heilmann
 
PDF
Single Page Application Best practices
Tarence DSouza
 
PDF
Performance.now() fast but not furious
Anna Migas
 
PDF
Advanced workflows for mobile web design and development
brucebowman
 
PDF
Intro to Web Development from Bloc.io
Douglas Wright
 
PDF
JavaScript Promises and the issue of Progress - SmashingConf Freiburg Jam Ses...
Christian Heilmann
 
PDF
Progressive Web App Challenges
Jason Grigsby
 
PDF
IV - CSS architecture
WebF
 
PDF
Dangerous CSS
Mike Wilcox
 

More Related Content

What's hot (20)

PDF
Progressive Web Apps - Bringing the web front and center
Christian Heilmann
 
PPTX
That's crazy! how to build single page web apps
Chris Love
 
PDF
Web Development for UX Designers
Ashlimarie
 
PPTX
2021 Chrome Dev Summit: Web Performance 101
Tammy Everts
 
PDF
[jqconatx] Adaptive Images for Responsive Web Design
Christopher Schmitt
 
PDF
The Progressive Web and its New Challenges - Confoo Montréal 2017
Christian Heilmann
 
PPTX
Make JavaScript Faster
Steve Souders
 
PPTX
Doing Modern Web, aka JavaScript and HTML5 in the Enterprise
Chris Love
 
PDF
Stapling and patching the web of now - ForwardJS3, San Francisco
Christian Heilmann
 
PDF
Progressive Web Apps – the return of the web? Goto Berlin 2016
Christian Heilmann
 
PDF
A New Hope – the web strikes back
Christian Heilmann
 
PDF
Dreamweaver CS6, jQuery, PhoneGap, mobile design
Dee Sadler
 
PDF
The Soul in The Machine - Developing for Humans (FrankenJS edition)
Christian Heilmann
 
PDF
Single Page Application Best practices
Tarence DSouza
 
PDF
Performance.now() fast but not furious
Anna Migas
 
PDF
Advanced workflows for mobile web design and development
brucebowman
 
PDF
Intro to Web Development from Bloc.io
Douglas Wright
 
PDF
JavaScript Promises and the issue of Progress - SmashingConf Freiburg Jam Ses...
Christian Heilmann
 
PDF
Progressive Web App Challenges
Jason Grigsby
 
Progressive Web Apps - Bringing the web front and center
Christian Heilmann
 
That's crazy! how to build single page web apps
Chris Love
 
Web Development for UX Designers
Ashlimarie
 
2021 Chrome Dev Summit: Web Performance 101
Tammy Everts
 
[jqconatx] Adaptive Images for Responsive Web Design
Christopher Schmitt
 
The Progressive Web and its New Challenges - Confoo Montréal 2017
Christian Heilmann
 
Make JavaScript Faster
Steve Souders
 
Doing Modern Web, aka JavaScript and HTML5 in the Enterprise
Chris Love
 
Stapling and patching the web of now - ForwardJS3, San Francisco
Christian Heilmann
 
Progressive Web Apps – the return of the web? Goto Berlin 2016
Christian Heilmann
 
A New Hope – the web strikes back
Christian Heilmann
 
Dreamweaver CS6, jQuery, PhoneGap, mobile design
Dee Sadler
 
The Soul in The Machine - Developing for Humans (FrankenJS edition)
Christian Heilmann
 
Single Page Application Best practices
Tarence DSouza
 
Performance.now() fast but not furious
Anna Migas
 
Advanced workflows for mobile web design and development
brucebowman
 
Intro to Web Development from Bloc.io
Douglas Wright
 
JavaScript Promises and the issue of Progress - SmashingConf Freiburg Jam Ses...
Christian Heilmann
 
Progressive Web App Challenges
Jason Grigsby
 

Similar to CSS vs. JavaScript - Trust vs. Control (20)

PDF
IV - CSS architecture
WebF
 
PDF
Dangerous CSS
Mike Wilcox
 
PDF
Flexbox, Grid and Sass
Seble Nigussie
 
PDF
Knowing it all
Rachel Andrew
 
PDF
CSS3 Refresher
Ivano Malavolta
 
PPTX
cascading style sheet powerpoint notes.pptx
kcdiya58
 
PPTX
GDG On Campus NBNSCOE Web Workshop Day 1 : HTML & CSS
udaymore742
 
PDF
CSS3 - is everything we used to do wrong?
Russ Weakley
 
PDF
Simply Responsive CSS3
Denise Jacobs
 
PPT
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Deepak Sharma
 
PPT
Css best practices style guide and tips
Chris Love
 
PPTX
CSS Walktrough Internship Course
Zoltan Iszlai
 
PPTX
CSS3 notes
Rex Wang
 
PPTX
Cordova training - Day 2 Introduction to CSS 3
Binu Paul
 
PDF
CSS3: Ripe and Ready to Respond
Denise Jacobs
 
PDF
Evolution of CSS
Ecaterina Moraru (Valica)
 
PDF
presentation
Mart Bosch
 
PPT
Web design-workflow
Peter Kaizer
 
PPTX
Krishan gaurav-sapient bootstrapsession
Krishan Mohan
 
PPTX
Introduction to HTML+CSS+Javascript.pptx
deepuranjankumar2002
 
IV - CSS architecture
WebF
 
Dangerous CSS
Mike Wilcox
 
Flexbox, Grid and Sass
Seble Nigussie
 
Knowing it all
Rachel Andrew
 
CSS3 Refresher
Ivano Malavolta
 
cascading style sheet powerpoint notes.pptx
kcdiya58
 
GDG On Campus NBNSCOE Web Workshop Day 1 : HTML & CSS
udaymore742
 
CSS3 - is everything we used to do wrong?
Russ Weakley
 
Simply Responsive CSS3
Denise Jacobs
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Deepak Sharma
 
Css best practices style guide and tips
Chris Love
 
CSS Walktrough Internship Course
Zoltan Iszlai
 
CSS3 notes
Rex Wang
 
Cordova training - Day 2 Introduction to CSS 3
Binu Paul
 
CSS3: Ripe and Ready to Respond
Denise Jacobs
 
Evolution of CSS
Ecaterina Moraru (Valica)
 
presentation
Mart Bosch
 
Web design-workflow
Peter Kaizer
 
Krishan gaurav-sapient bootstrapsession
Krishan Mohan
 
Introduction to HTML+CSS+Javascript.pptx
deepuranjankumar2002
 
Ad

More from Christian Heilmann (20)

PPTX
Develop, Debug, Learn? - Dotjs2019
Christian Heilmann
 
PDF
Hinting at a better web
Christian Heilmann
 
PDF
Taking the "vile" out of privilege
Christian Heilmann
 
PDF
Seven ways to be a happier JavaScript developer - NDC Oslo
Christian Heilmann
 
PDF
Artificial intelligence for humans… #AIDC2018 keynote
Christian Heilmann
 
PDF
Killing the golden calf of coding - We are Developers keynote
Christian Heilmann
 
PDF
Progressive Web Apps - Techdays Finland
Christian Heilmann
 
PDF
Taking the "vile" out of privilege
Christian Heilmann
 
PDF
Five ways to be a happier JavaScript developer
Christian Heilmann
 
PDF
Taking the P out of PWA
Christian Heilmann
 
PDF
Sacrificing the golden calf of "coding"
Christian Heilmann
 
PDF
You learned JavaScript - now what?
Christian Heilmann
 
PDF
Sacrificing the golden calf of "coding"
Christian Heilmann
 
PDF
Progressive Web Apps - Covering the best of both worlds - DevReach
Christian Heilmann
 
PDF
Progressive Web Apps - Covering the best of both worlds
Christian Heilmann
 
PPTX
Non-trivial pursuits: Learning machines and forgetful humans
Christian Heilmann
 
PDF
Supercharging Public Speaking
Christian Heilmann
 
PDF
The Soul in The Machine - Developing for Humans
Christian Heilmann
 
PDF
Suit up, bring extra oxygen Internet space explorers needed.
Christian Heilmann
 
PDF
Microsoft und die Open Source Community - Leaving the death star behind
Christian Heilmann
 
Develop, Debug, Learn? - Dotjs2019
Christian Heilmann
 
Hinting at a better web
Christian Heilmann
 
Taking the "vile" out of privilege
Christian Heilmann
 
Seven ways to be a happier JavaScript developer - NDC Oslo
Christian Heilmann
 
Artificial intelligence for humans… #AIDC2018 keynote
Christian Heilmann
 
Killing the golden calf of coding - We are Developers keynote
Christian Heilmann
 
Progressive Web Apps - Techdays Finland
Christian Heilmann
 
Taking the "vile" out of privilege
Christian Heilmann
 
Five ways to be a happier JavaScript developer
Christian Heilmann
 
Taking the P out of PWA
Christian Heilmann
 
Sacrificing the golden calf of "coding"
Christian Heilmann
 
You learned JavaScript - now what?
Christian Heilmann
 
Sacrificing the golden calf of "coding"
Christian Heilmann
 
Progressive Web Apps - Covering the best of both worlds - DevReach
Christian Heilmann
 
Progressive Web Apps - Covering the best of both worlds
Christian Heilmann
 
Non-trivial pursuits: Learning machines and forgetful humans
Christian Heilmann
 
Supercharging Public Speaking
Christian Heilmann
 
The Soul in The Machine - Developing for Humans
Christian Heilmann
 
Suit up, bring extra oxygen Internet space explorers needed.
Christian Heilmann
 
Microsoft und die Open Source Community - Leaving the death star behind
Christian Heilmann
 
Ad

Recently uploaded (20)

PPTX
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
PDF
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
PPTX
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
PDF
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
PPTX
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
PPTX
Peer Teaching Observations During School Internship
AjayaMohanty7
 
PDF
Hurricane Helene Application Documents Checklists
Mebane Rash
 
PPTX
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
AndrewBorisenko3
 
PDF
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
PPTX
Photo chemistry Power Point Presentation
mprpgcwa2024
 
PPTX
How payment terms are configured in Odoo 18
Celine George
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
PPTX
How to Add New Item in CogMenu in Odoo 18
Celine George
 
PPTX
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
IIT Kharagpur Quiz Club
 
PPTX
List View Components in Odoo 18 - Odoo Slides
Celine George
 
PDF
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
PPTX
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
PDF
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
PPTX
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
PPTX
How to use _name_search() method in Odoo 18
Celine George
 
NSUMD_M1 Library Orientation_June 11, 2025.pptx
Julie Sarpy
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
2025 Completing the Pre-SET Plan Form.pptx
mansk2
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
Peer Teaching Observations During School Internship
AjayaMohanty7
 
Hurricane Helene Application Documents Checklists
Mebane Rash
 
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
AndrewBorisenko3
 
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Photo chemistry Power Point Presentation
mprpgcwa2024
 
How payment terms are configured in Odoo 18
Celine George
 
Aprendendo Arquitetura Framework Salesforce - Dia 02
Mauricio Alexandre Silva
 
How to Add New Item in CogMenu in Odoo 18
Celine George
 
Great Governors' Send-Off Quiz 2025 Prelims IIT KGP
IIT Kharagpur Quiz Club
 
List View Components in Odoo 18 - Odoo Slides
Celine George
 
Gladiolous Cultivation practices by AKL.pdf
kushallamichhame
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
GREAT QUIZ EXCHANGE 2025 - GENERAL QUIZ.pptx
Ronisha Das
 
How to use _name_search() method in Odoo 18
Celine George
 

CSS vs. JavaScript - Trust vs. Control