Apple has released an OS update. Packaged in with it is the latest version of Safari, 16.
Expected to be released ahead of next monthâ€™s macOS 13, Safari 16 is packed with updates, making it one of the most capable browsers available.
Some of this was announced in June in the Safari 16 beta. But a lot has been added in the last couple of months. So hereâ€™s whatâ€™s new in Safari 16 today.
CSS Container Queries
The most exciting addition to Safari 16 is CSS Container Queries.
It is hard to understate how in-demand this feature has been; if you imagine an edit button on Twitter that gifted you crypto every time you corrected a typo, youâ€™d be getting close to how popular this feature is.
Until now, media queries have detected the whole viewport. And so, if you have an element like a card, for example, that needs to change at smaller viewports, you need to calculate the available space and adapt the elementâ€™s design accordingly. Unfortunately, this frequently gets out of sync with edge cases causing more than a few headaches for front-end developers.
Media queries are severely restrictive to modern layout methods like Grid that wrap elements automatically because there is no way to detect how the elements are laid out.
Container Queries solve this by allowing you to define styles based on the size of the actual containing element; if a div is 300px wide, the contents can have one design, and if itâ€™s 400px wide, they can have a different designâ€”all without caring what size the whole viewport is.
This is dangerously close to OOP (Object Orientated Programming) principles and almost elevates CSS to an actual programming language. (All we need is conditional logic, and weâ€™re there.)
The latest versions of Chrome, Edge, and now Safari (including mobile) support CSS Grid. Even discounting the rapid decline of Twitter, this is way more exciting than any edit button.
Speaking of Grid, if youâ€™ve built a site with it (and if you havenâ€™t, where have you been?), youâ€™ll know that matching elements in complex HTML structures often results in nesting grids. Matching those grids requires careful management, CSS variables, or both. With CSS Subgrid, grids can inherit grid definitions from a grid defined higher up the hierarchy.
CSS Subgrid has been supported by Firefox for a while but is not yet part of Chrome or Edge. Until thereâ€™s wider support, itâ€™s not a practical solution, and using a fallback negates any benefit of using Subgrid. However, its introduction in Safari will surely herald rapid adoption by Google and Microsoft and moves the web forward considerably.
CSS Subgrid is likely to be a practical solution within 18 months.
AVIF is an exceptionally compact image format that beats even WebP in many instances. It even allows for sequences, creating what is essentially an animated GIF but smaller, and for bitmaps.
AVIF is already supported by Chrome, with partial support in Firefox. Safari now joins them.
AVIF support is one of the more valuable additions to Safari 16 because youâ€™re probably already serving different images inside a picture element. If so, your Safari 16 users will begin receiving a smaller payload automatically, speeding up your site and boosting UX and SEO.
Safari 16 introduces some significant improvements in animation, but the one that catches the eye is that you can now animate CSS Grid.
Yes, let that sink in. Combine Container Queries and animation. The possibilities for hover states on elements are tantalizing.
Chrome, Edge, and Firefox all support CSS Offset Path; the addition of Safari means itâ€™s now a practical solution that can be deployed in the wild.
Web Inspector Extensions
Announced as part of the beta release, Web Inspector Extensions allow web developers to create extensions for Safari, just as they would for Chrome.
Web Inspector Extensions â€” or Safari Extensions as theyâ€™re destined to be known â€” can be built in HTML, CSS, and JS, so the learning curve is shallow. Itâ€™s a good route into app development for web designers.
Because the underlying technology is the same as other browser extensions, anyone who has made a Chrome, Edge, or Firefox extension will be able to port it to Safari 16+ relatively easily. As a result, there should be a rapid expansion of the available extensions.
Accessibility is key to an effective and inclusive web. Be like Bosch: everybody counts, or nobody counts.
When testing a design for accessibility, emulators donâ€™t cut it. In my experience, Safari has some of the most reliable accessibility settings, especially when it comes to Media Queries like prefers-reduced-movement.
Further gains in this field mean that Safari continues to be an essential tool for QA tests.
Finally, I want to throw up my hands to celebrate the reduced number of non-standard CSS appearance settings.
For years weâ€™ve been prefacing our style sheets with elaborate resets like Normalize, designed to undo all the assumptions browser developers make about design and the UI preferences of their engineers.
Safari 16 has reportedly â€śRemoved most non-standard CSS appearance values.â€ť How effective this is and how much we can rely on it given the other browsers on the market remains to be seen. However, like many of Safari 16â€™s changes, itâ€™s a step towards a browser thatâ€™s on the developersâ€™ side instead of an obstacle to overcome.