How to Write CSS That Works in Every Browser, Even the Old Ones
hacks.mozilla.org
hacks.mozilla.org
You can skip the first one, that is a verbose introduction that starts with CERN web history. Key message: "build for all deviecs". No more valuable info, unfortunately, and I have to spend time now on other things.
I am sure 10 minutes reading an article I would have been able to extract some more.
Advice to video tutorial makers: please value your viewers time most, make this a very high priority in your production workflow. Think twice about every sentence you write into the playbook and after one or two days write the sentences again with a target of 50% time reduction. Absolutely never just talk ten minutes something that just comes into your mind - this will just waste the viewers time. Tutorials are not for time wasting. Keep the information very precise and to the point. Always provide at least a cheat sheet of key info. Thanks!
While reading text it's pretty hard to be doing something else at the same time
There's also the factor of when I'm reading I read at my speed in my voice. I'm not distracted by a particularly nasally voice[0] or a slow talker rambling on
[0] Not saying the videos here are that, it's just one of those voice types that I remember being different enough to become distracted
Tip: if you want to quickly see the Video headings CTRL + F or CMD + F and type in Video so that you can highlight it. I don't know how to make proper headers on HN.
Video 2
The whole theme of video 2 is: what can I get away with?
caniuse.com
statcounter.com (caniuse.com uses it as a data source)
Use GA to see what you can get away with
chromestatus.com
developer.microsoft.com/en-us/microsoft-edge/platform/status
platform-status.mozilla.org
bugzilla.mozilla.org
Edit video 3:
What happens when a feature isn't supported and you use it?
It strikes it through. / It ignores it.
It's okay that websites don't look identical in every browser. In fact, they never ever do.
CSS is not like JS where it breaks / generates an error. It just ignores stuff it doesn't know.
shape-outside circle example: it works when it works. It is a square if it doesn't work. Users won't necessarily know that it is different.
shape-outside polygon example: it works with supported browsers and is a square when it doesn't work.
CSS Error handling: it just ignores stuff
Edit video 4:
Counting on how CSS handles is enough. Other times it is not quite enough. You want to make adjustment for browsers that do not support many things. CSS Overrides help.
Basic example: the header is the height of the viewport.
header { display: flex; height: 100vh; }
h1 { margin: auto; }
What happens in browsers that do not support display flex? The functionality gets lost. Client in said example says it wants a bigger height for older browsers.
Solution: header { display: flex; height: 500px; height: 100vh; }
h1 { margin: auto; }
caniuse viewport units caniuse flexbox
Browser supports viewport units but not flexbox. We want the headline in the middle Solution: header { display: flex; height: 500px; height: 100vh; }
h1 { padding: 2em 0; /* cannot use margin since the next line overwrites margin / margin: auto; }
Check 5:30 for all the different output examples
Firefox inspector: play with CSS.
Edit video 5: feature queries
caniuse initial-letter? Not really, only in Safari
p::first-letter { color: rgba(255, 255, 255, 0,9); font-weight: bold; margin-right: 0.5em;
-webkit-initial-letter: 4;
initial-letter: 4;
}Initial-letter makes a giant initial letter.
Feature queries look like this:
@supports (initial-letter: 4) or (-webkit-initial-letter: 4) { p::first-letter { color: rgba(255, 255, 255, 0,9); font-weight: bold; margin-right: 0.5em;
-webkit-initial-letter: 4;
initial-letter: 4;
}
}This means that browsers that do not support it, won't show it.
Example of grid and how feature queries help when grid isn't applied.
Code is on 7:15. It is too big to write.
8:30 is more in-depth on the syntax of @supports
There is also one bad idea to use @supports and this is: @support not
Edit video 6: feature queries advanced info
Every version of IE does not know what a feature query is. Safari also did not know it for a long time.
What they do is: they block the whole code.
There are 4 combinations:
(1) browsers that support feature queries && do understand the specific feature
(2) browsers that support feature queries && do not understand the specific feature
(3) browsers that do not support feature queries && do understand the specific feature
(4) browsers that do not support feature queries && do not understand the specific feature
We do not want (3).
Example
@supports (display: flex){ / code */ }
When using feature query know that you ignore Internet Explorer and Safari.
With older properties you might not want to use feature queries (e.g. flexbox), but for new feature queries you may want to.
Edit video 7: what happens when the browser doesn't understand the CSS?
Ask yourself: how well does a particular feature fail?
Maybe you don't want to use the property at all because it fails horribly.
Example:
h1 { writing-mode: sideways-lr; }
caniuse writing-mode? yes 94%
Yet in most browsers sideways-lr doesn't work in most browsers!
Why does caniuse lie to us?!
caniuse represents the level 3 specification of writing-mode, but she is using level 4!
go to the MDN network to checkout support
One solution to this problem is to ignore the feature and create the same output like so:
h1{ writing-mode: vertical-rl; transform: rotate(180deg); text-align: right; text-orientation: sideways; }
[ speeddown
] speedup
v display speed settings
Speeds of 4x has audio cutoff, 16x is max playback speed
Also, enable captions on video helps out a lot when speeding through a video, in the event you misheard something at faster playbacks
Yes, please be good and build accessible websites, just because its actually not hard to do on a rudimentary level and your probably sucks if you don't anyway.
But actually working on CSS compatibility is such a waste of time considering how "good enough" all of the widely available options are. Yeah, you probably do not want to use the latest in web tech if you are doing a reasonably sized web project that loses actual money for every % of users that can not use the app/site. So what? Just don't. Unless it's a vanity project pick a reasonable cut off point, go with it for that project (or that iteration of the product) and then you reevaluate for the next one.
You can obviously use auto prefixer and the sorts to widen the margin -- everything you can automate, you don't have to think about, by all means, go for it. But the mental overhead you are creating by doing shit like "height: 500px; height: 100vw;" is insanity in a reasonably large project with multiple developers. I forbid you to do it.
By the time the next project comes, you can probably already set the cut off somewhere else. People are actually (being forced to) update their computer, and really enjoy throwing out their mobile devices every other year (thanks apple, I guess). I gladly reap those benefits.
> "height: 500px; height: 100vw;" is insanity in a
> reasonably large project with multiple developers.
> I forbid you to do it.
What have happened to us? Too many post on HN show this attitude: make it cheaper to develop, don't care about the users. What happen with the "zen of the web"?For one, I've started with the web around the time CSS was being born—2016. And in your example I see neither insanity nor large overhead, just a robust approach.
I started doing webdev in 1998 and gently suggest you check your notes.
2. Leverage CSS override
3. Use browser devtools to test all browsers. No need install all older browser to check CSS. icanuse helps greatly too.
4. Use feature-queries for CSS.
These indeed can make your CSS code work for both the stone age and hottest browsers, all at the same time, without much hacking. Great videos.
I wish there was a browser version that would handle these errors loudly rather than silently. The fact that React does some of this is rather nice.
Can you, for example, make a half broken PDF and would it still render?
So yeah, I bet you can.
I certainly remember taking a really old version of IE (2 or 3 I think?) for a spin and running into problems because it didn't support SNI.
Remember when console.log broke ie? Debugging was fun.
[1]: https://developer.mozilla.org/en-US/docs/Archive/Web/LiveCon...
In dev only, I hope?! I honestly love the idea as a super fun hack, but the security implications for prod are terrifying.
This is false information about Safari. In fact, Safari was the first browser to implement 100% ES2015 support.
https://developer.apple.com/safari/technology-preview/releas...
It seems unreasonable to me to expect to run new language features on old runtimes, do you have a good reason to not use Babel and move on? I've been writing ES6 (with Babel) from > 2 years now and have never regretted the move.
I get the appeal of partying like it's 1999 but as someone who used JS in the 1990s these are things I would not want to live without. I'm perfectly capable of writing ES3 code without any tooling but I'd rather not.
I know JS is JIT, but with tools like Babel and webpack and sourcemapping, that doesn’t mean we have to write the same code that’s executed. New code is so much more resilient. Remember: this is what we evolved to.
The boss became kind of `jealous` of my skill and the praises i got for it, and would complain that the website did not look perfect on every browser, sending me screenshots of broken sites on his computer.
I spent about 2 months making sure they looked pristine on ALL browsers on ALL platforms, even installing Mandrake Linux and RedHat 7.20 (iirc) just to test them.
No dice, sites still malfunctioning on the boss' pc, who was really happy I couldn't make perfect sites. The more i got obsessed with it the worse the sites would look on his ie6 browser.
After yet another smug comment from him I stormed his office in a rage fueled raid and i ran to his pc shouting that this is IMPOSSIBLE, grabbed his mouse and clicked on the "?" menu and About.
He was using some obscure chinese aternative modded version of ie6 (iirc UC Browser), probably installed just to complicate my life.
tl;dr: vaffanculo, Marco.
What a waste of time and resources, hiding knowledge in video is the among most inconvenient and inefficient way of making it useful: no indexing, ni skimming, no copy pasting, it's slow, cannot be searched, cannot be put in a translator, cannot be mirrord, uses much more resources.
Then it's hosted on youtube which is the worst offender privacy wise and does not work without allowing script from a few different domains.
Once again mozilla fails to deliver according to their supposed values which are mostly marketing.
Why do I have to relinquish my privacy to endure an inconvenient and inefficient way to learn when it could have been written in the very same page with text which will survive time and can be easily mirrored. Why put such an unecessary wall between knowledge and audience ?
On the serious note: this is not some unique knowledge that is available in those videos. Much of this stuff was there for years, everywhere. Those who enjoy listening to Jen talking will watch the videos. Others do not have to.
B2B, it shocks me how often we run into old-browser problems. IE8 is the biggest one I encounter day-to-day. Sure, it's been EOL for 2 years, and was released almost a decade ago, but... it still lives on within organizations that we have to support.
It's just a shame there isn't 'crappy backwards business/bank' setting to show up the real usage of IE8.
(Not doubting your experience, just surprised that it would be because of grid and not some other feature).
This was about half a year ago.
For people using forks for the old extension system, why use an outdated engine lacking support for new features, instead of using a separate (native application|electron-based application|shell script)?
My guess is the addon site is using a strategy a lot of developers are taking, design a narrow mobile experience that doesn't use CSS Grid (because small screens typically have a single column layout anyway and most non-Grid supporting browsers are mobile) but make it fluid to work in larger viewports for any browser that doesn't support CSS Grid. Not every browser has to have the exact same experience, it's something Jen covers in this video series.
BTW, Firefox ESR 52 supports CSS Grid and addons that aren't supported in 57 and later. I think some of the forks are only needed to run unsigned extensions, which sounds like a bad idea.
I am on the right side of this, and most other fights, but you are killing me. When I am dead I hope you enjoy the hell that you will burn in.