Bits of Code
bitsofco.de · Personal blog · on HN since 2015
Ire Aderinokun writes web development tutorials on CSS, JavaScript, HTML, and browser features such as grid layout and service workers.
What HN saysCommenters link it as a clear reference for CSS Grid, srcset and sizes, service workers, and HTML outlines.
40HN people shared it
6linked it in comments
43stories submitted
659story points
5 years agolast shared
2015people per year2026
Most-shared posts
- 1Linting HTML using CSS2 people · 327 points · first shared 2017 · 49 comments on HN
- 2The :target Trick2 people · 9 points · first shared 2016 · discussion on HN
- 3Asynchronous Functions 1012 people · 7 points · first shared 2017 · discussion on HN
- 4[JS] You might not need a loop2 people · 5 points · first shared 2018 · discussion on HN
- 5What Is First Input Delay?2 people · 4 points · first shared 2018 · discussion on HN
- 6Recreating the GitHub Contribution Graph with CSS Grid Layout2 people · 3 points · first shared 2018 · discussion on HN
- 7“What's the typeof null?”, and other confusing JavaScript Types2 people · 3 points · first shared 2017 · 1 comments on HN
- 8Web workers vs. Service workers vs. Worklets2 people · 3 points · first shared 2018 · discussion on HN
- 9The Holy Grail Layout with CSS Grid2 people · 2 points · first shared 2017 · discussion on HN
- 10The New System Font Stack?2 people · 1 points · first shared 2016 · discussion on HN
- 11What I wish I knew about React1 people · 236 points · first shared 2020 · 290 comments on HN
- 12I created 488 “live images” of CanIUse using puppeteer1 people · 15 points · first shared 2019 · discussion on HN
- 13A look at CSS Resets in 20181 people · 6 points · first shared 2018 · discussion on HN
- 143 New CSS Features to Learn in 20171 people · 4 points · first shared 2017 · discussion on HN
- 15What, exactly, is the DOM?1 people · 4 points · first shared 2018 · discussion on HN
What HN people wrote when they linked it
mjgs · 2021-04-07
I was thinking that a service worker could be used:
https://bitsofco.de/web-workers-vs-service-workers-vs-worklets/#servic…
If the url returns a 404, check the internet archive, if it’s there then return that otherwise return a 404.
If CORS is an issue just proxy the requests via the server that is serving the website.
RobertRoberts · 2018-02-05
Yes, but grid/css is _designed_ for layout. Tables was a bastardization of markup designed for data display. (ie, a table of data, like in a spreadsheet)
Unless you have truly dug into how awesome grid is, you can't really understand what it's done for the future of web design.
I will look up a short tutorial I ran into that really showed me the power/value of grid. (fyi, I use CSS daily in my work)
Edit: Here's one example. You could use tables, but this is incredibly flexible and with media queries you can completely manipulate the layout and position of the design based on the screen size. And the markup is incredibly light, it's fabulous for those of us who want more control and less work to do, _and_ less debugging of browser quirks.
https://bitsofco.de/github-contribution-graph-css-grid/
detaro · 2017-04-16
For a relatively standard problem (the "holy grail layout", 3 equal-height columns with header and footer), this article isn't bad: https://bitsofco.de/holy-grail-layout-css-grid/
http://gridbyexample.com/ is another nice resource.
corny · 2017-02-20
It looks like that method is now deprecated in HTML 5.1.
https://bitsofco.de/document-outlines-in-html-5-1/
Cyberdog · 2021-08-12
This is some pretty powerful stuff. Here's a more information-dense and up-to-date rundown of srcset and sizes: https://bitsofco.de/the-srcset-and-sizes-attributes/
Notably, it shows how it's possible to use different images based on a portrait or landscape layout of the viewport, which OP doesn't cover. That's not always useful but it's good to know it's there when you might want to use it.
I was recently (well, several months ago) tasked with improving the Google PageSpeed scores on mobile for a site which has a lot of image-heavy pages. The end solution involved adapting all images to use a <picture> image with a WebP alternative for browsers that can show it (Google's tools like it when you use their near-proprietary image format; go figure), plus using srcset and sizes (which can be used on <source> tags inside of <picture> tags as well as <img> tags) plus a script which resizes and caches resized versions of large images based on URL parameters (basically an ersatz Glide [0]; I wish I had known it existed when I started). The end result severely reduced page weight for mobile visitors and was successful in raising our PageSpeed scores and appeasing my client.
[0]: https://glide.thephpleague.com
ggreer · 2018-11-18
It took me a while to figure out that links in the text were ALL CAPS instead of underlined and/or blue. The hover effect was so subtle that I didn't notice it at first. I ended up hovering over acronyms pretty often, as I was never sure if those were also links. That is not good design.
There's also the issue that while the site may look pretty, it requires downloading 5 megabytes of CSS.
At every job I've had, designers who talked about typography created more problems than they solved. They picked fonts that were less readable but more unique, "To emphasize our brand." They chose web fonts that hurt page load times and had kerning and hinting issues on platforms besides macOS. They chose thin font weights and gray text colors because those looked nice when viewed indoors on retina displays with young eyes.
Almost every site could be improved by doing less with fonts, not more. For long form text, use a popular serif font. For user interfaces, use the system font stack.[1] Don't ship web fonts except for icons. Most importantly: Use high contrast and normal font weights. Thin gray fonts are extremely hard to read if you're outdoors or using an older/cheaper screen.
1. https://bitsofco.de/the-new-system-font-stack/