But did you know the browser already does that? with James Stuckey Weber

This video features James at DjangoCon US 2026 in Chicago, Illinois, USA.

But did you know the browser already does that? with James Stuckey Weber
0:25:34
Published October 26, 2026
1,179 views

New features in HTML and CSS mean a better dev experience for providing better user experiences. But are they too new to use? In this talk, you'll get a glimpse at some of the newer features of the web platform. Once you're excited to use them in your project, we'll take a look at browser support, and how to use Baseline to evaluate whether it's ready to use in your project.

We will cover:

Popovers: native tooltips
Anchor positioning: placing tooltips and dropdowns
Invokers: interactivity without needing JavaScript
Container queries: styles based on context, not the screen
View transitions: Animating between pages
Custom selects: Native select options that match your UI

And more!

But how do you know if a feature has enough support? You will also learn how easy it is to evaluate support with Baseline, which is integrated into IDEs, linters, and throughout the web.

This talk was presented by James Stuckey Weber at DjangoCon US 2026 in Chicago, Illinois, USA
https://2026.djangocon.us/talks/but-did-you-know-the-browser-already-does-that/

LINKS:
Follow James Stuckey Weber 👇
On Mastodon: https://front-end.social/@jamessw
Website: https://www.oddbird.net/authors/james/

Transcript

4,490 words · auto-generated · en Show

Automatically transcribed, so expect mistakes in names and technical terms.

0:15

Good afternoon. First of all, thank you to all the speakers and organizers who have made this a really great Django Khan. Let's give them a round of applause. So I'm a birder, um, and I need to actually get this started. Uh I'm a birder meaning I enjoy finding, tracking, and learning about birds. Before I started learning about birds, I vaguely knew they existed and I even was convinced that they are real. I still am. Once I learned a bit more about birds, it opened up a whole new world. I could stand in my backyard and wherever before there was just noise. suddenly there were sandhill cranes or a ruby-throated hummingbird flying overhead. Just knowing to pay attention changed what I noticed and turned background noise into a signal.

1:02

And then I would go on a walk and see this little blur and have no idea what I was looking at, but know enough to know that it was out of place. I had developed the tools and resources to figure out eventually that this was an American Avicet. Which is rare enough for my area that birders flock to see it. And that's my hope for this talk. I want to introduce you to just enough of the features so that when you encounter a use case for them in the wild, Even if you view HTML and CSS with suspicion, you'll know that the features exist and are real, why you should use them, and the tools to use to evaluate whether they are ready to be used. And you can follow along and see the demos and links at talks. jamsw. com. So besides being a birder, I'm a developer with Oddbird. And at Oddbird, we wear two hats. One is working on improving the web platform by defining new CSS

1:49

language features, creating documentation and tools for developers like polyfills and contrast checkers. Our other hat is using the web platform, usually backed by Django, to solve business problems for cabinet makers, metal foundries, nonprofits, and more. This puts us in a great position. To know all about the latest, fanciest things on the web while also keeping us rooted in the reality of what users need and how technologies actually work. We love working with the web platform and it's just getting better. Browsers have really been on a roll adding more and more features. Here are some of the newer features, more than I can possibly talk about today. Many of these are simply looking at what people are needing third-party libraries for and seeing if they can be done by the browser with more security, performance, or developer ease.

2:35

So for instance, lots of Lodash feat uh methods are just available in JavaScript now. And native CSS can do much of what SaaS can do. So this is valid CSS with no compile step. You have variables, nesting, custom functions are coming, and there's more. So Maybe you've noticed that I'm not talking about novel functionality. I'm not talking about adding scratch and sniff smells to your website or converting your gifts into holograms when printed. These are authoring conveniences that allow you to deliver faster and user experiences that your users and your designers expect. They allow you to make better websites that load faster and um and work faster, they're more secure, and have fewer dependencies to manage. That's a dream. So perhaps a more honest title for this talk would have been, but did you know your user's browser maybe does that?

3:27

With all these new features constantly being released, how do you keep track of whether you can use a new feature? Remember this is front end, that the code you're writing isn't run on your computer. It's not like Django where it's running on a server you provision and control. By making content available on the internet, you're giving up a ton of control. Or to frame it differently, you have the opportunity to collaborate with each of your users to provide them with the content and tools they want, with their unique preferences on how it's presented. So to quote my fellow Oddbird, web development is essentially graphic design of unknown content with unknown collaborators on an infinite and unknowable canvas across operating systems, interfaces, languages, and writing modes. So how can you make an informed decision on whether you can use a feature and make sure it works for your users?

4:17

Maybe you check out can I use, but what is this telling you? This is a lot of data. Maybe you've come across a table like this on MDN. So that is backed by a project called Browser Compat Data, or BCD, which tracks individual parts of the web platform They track 15,000 different items. It can tell you when support was added for the minmax function on grid template columns, for instance. Way too granular and not how devs talk about things. So there's a need for a more general way of talking about features, and that's where the Web Features project comes in. I was part of an of an effort to distill those 15,000 web API parts into something closer to how developers think. It's currently at 1,100 different features. So for instance, it can answer

5:02

when was all of the grid funk functionality supported? When was subgrid added as a new feature? So the web feature or the web features project groups parts of the web platform into manageable chunks, but how do you know if things are ready to use? Enter baseline. I'm curious uh how many of you have heard of baseline? Okay, there's a couple. This is great. Baseline asks if if a feature is ready to use in Chrome, Edge, Safari, and Firefox. By ready to use, it's more than just base support. It's asking a group of experts if the feature as a whole is bug-free and works consistently across browsers. In other words, can you just expect it to work? And the second part is if it's been available for 30 months, which is enough time to get most people updated.

5:50

It isn't going to be 100%, but it's probably close enough depending on your audience. So if it fully meets those criteria, it's considered baseline widely available. If it's in all the browsers, but for less than 30 months. Then it's considered baseline newly available. And if it's not available in all browsers, it has limited availability. And then you can use these classifications to inform your decisions on whether to use something in your app. But it isn't useful if you have to remember to go looking for it. If you use VS Code, it's available in the tooltip when you hover over some selector, for instance, in CSS. It's also available on MDN. You can integrate it with your Lint tools for CSS. It's available as a styLint plugin, or as a rule for ESLint, or available wherever you use browsers

6:39

list. So let's see how this plays out with one feature, the CSS light-dark function. Yesterday we heard a great talk from Sarah Abdurahman on the thought and care that went into implementing light and dark mode on the Django site. Thanks, by the way, both for the talk and for the feature. So inspired by the talk, I figured we'd start with this. So this is the general pattern of uh what that's used on the Django site, where you first write your light styles generally, then you write your dark styles separately wrapped in a media query With light dark, you can set the colors for light and dark mode in one line without a preferred color scheme media query. Um you first write the uh for instance the background would be white on a light in a light theme and black. um in a dark theme.

7:25

So why do I agree with the decision to not use this on the Django website? As you can see, This is in all the major browsers right now, but since May of 2024. This means it's newly supported with wide support coming in November. If the baseline definition works for the Django website audience, you need to give it a bit more time, but you could start learning about this and get ready to use it. And support for setting light and dark versions of images is coming as well. So are you seeing how baseline can inform your decisions? CSS has also progressed well behind beyond the hexadecimal RGB colors that you know and love. RGB colors are limited to just a subset of what many monitors can show. The CSS color function Allows you to specify wide gamut colors in new color spaces like display P3 and Rec2020, and that's widely available.

8:16

You can start using those now. And you can specify the color space to create your gradients in and even which direction to interpolate in for hues. And this is especially nice with two new color functions, OKLab and OKLCH, which are cal calculated to be perceptually uniform. This means if you're just trying to change the hue of color and not the lightness or saturation, there are going to be fewer shifts to colors in between with different saturations and lightness. And gradient interpolation is newly available, but it's coming soon. The OKLab and OKLCH spaces are widely available. You do need to be somewhat cautious though, as it's possible to quickly create imaginary colors, which Which is fun. And browsers do not yet properly map that to the screen's gamut.

9:04

So then there's relative uh color syntax, and this is in CSS, you can dynamically generate new colors from one base color. Calculating individual channel hues. Here we start with a blue and make the lightness channel a little bit lighter, keep the chroma the same, and shift the hue by 30 degrees. And that will be widely available next year. Another exciting feature is the ability to use the index of an element in a list and the count of its siblings in CSS, which is Kind of hard to explain without an example. So for instance, you can delay an animation by a multiplier of the sibling index creating a staggered effect. You can rotate an element based on how many siblings it has, or offset a color's hue by its relative position amongst its siblings. Um

9:49

let's see if we We can no internet. Let's see if we can get this to load. There we go. So here we have some divs, and we can change how many divs there are. And no matter how many divs there are, the code on the previous things, it's calculating that or the the colors and the staggered animation all using the sibling index And that is newly supported as of last week. Next, let's look at a deceptively simple uh pattern, the drop-down menu. It always ends up being more complicated to implement correctly than I expect, and there are a lot of new features that are that together are making that a lot easier.

10:38

So a drop-down menu is initially closed until you click on a button. Then it needs to open on top of everything else and be positioned somewhat somewhere relative to the trigger, the button that you clicked. So this is the HTML for a simple drop-down menu. Just this, with no JavaScript, gets us three-quarters of the way. The command attribute on the button declares the click behavior. In this case, it will toggle the popover. The command for attribute declares what the behavior applies to. The popover attribute hides the menu by default. So when the button is clicked, my popover is opened. And because of the popover attribute, it is added to the top layer above above all your other content. That leaves us with just the fourth part, positioned relative to the trigger.

11:25

The button could be anywhere on the page, but the menu should open somewhere near it. For this, we'll use anchor positioning. Anchor positioning is a new alternative to absolute or relative positioning where you can tether one element to another wherever it may be. The position area property places the menu at the bottom of the button and spans the button's width and to its right. And let's see how that works so we have a button, we open it and it opens up the button, click outside, closes the popover, and that drop-down menu is uh above everything else with no Z-index shenanigans So looking at support, popover is supported since last year. We do have a polyfill if you want to use it today.

12:13

Anchor positioning is currently in all browsers, but remember how I said that baseline looks at more than just if something is there? In this case, the experts are looking at anchor positioning, and while the happy path works, there are a lot of edge cases and browser differences. Well you can certainly play around with anchor positioning and perhaps even use it. You do need to be aware that there be dragons with this. And you can use anchor positioning for more than popovers. You can do all sorts of fun and creative things. And this is an example of an emerging pattern called the follower pattern, where the selection indicator here uh is anchored to the hovered item and as you move the that around it it animates to whatever uh you're hovered over.

12:58

If you're wanting to learn more about anchor positioning, there's a lot there, a lot of things you can do. I have a free nine-week email course that walks you through the basics. Feel free to sign up for that. And we also maintain a polyfill if you want to use it while supporting older browsers. Based on Natalia's talk this afternoon, I gather there might be interested in avoiding JavaScript. In that case, invoker commands. That's how we declaratively toggle the popover, the command and command for attributes. You can even create custom commands to declaratively trigger an event that you create on an element. This is all uh coming soon. So using these features, we can implement a quite complex navigation menu, all without JavaScript here. So For instance, popover

13:44

is handled where we click outside, it closes. You can only have one popover at once. Submenus are automatically handled where if we click out here, it closes that. We can change to another one in there. Clicking a different popover closes all the uh submenus that were open. Um overflow management is handled by uh anchor positioning. So if if your button is close to one end of the screen, it will just move things to where it should be on the screen. There's also keyboard control in here automatically. It's all this is all Just working with keyboards. And there's no Z Index shenanigans. It's everything is on a new top layer above everything else. So if that sounds like too much work, let's take a look at an easy win. If you have a photo-heavy site, you likely tried tracking the user's scroll position and guessed when to best load off-screen pictures so they don't block the initial render.

14:37

That's a hard way, don't do that anymore. Let's do it the lazy way. Literally just adding load or loading lazy to images that are rendered off-screen. They won't load until you need them. And that's all that you need to do. That's widely supported and you and ready to use today. And it's coming for video and audio elements as well. This morning, Karen Tracy told us about the exciting addition of content security policies in Django 6. This is a new policy called Trusted Types, and you can enable it on your site. add it as a rule and it it ensures any content being written to the DOM with inner HTML or any other method, it first gets run through a sanitizer that you define.

15:23

And there's a sanitizer API coming which as well, which can replace third parties like DOM Purify and very performant and secure in the browser. Text layout has long been a struggle, especially when trying to go from the pixel-perfect design mockups to something that looks good on multiple screen sizes. There have been a lot of improvements that make it easier for your text to just look good. When a header wraps across multiple lines, you probably want each line to be roughly the same length. That's hard to do, especially when you're trying to solve that for lots of uh different headlines. Text wrap balance solves that by finding the combination of lines that best wraps. And so if we change what's on one side, the the text wrap on the left, it's just going to move things around like normal.

16:08

Text wrap balance. It will find a balanced uh uh way of making that headline look good. As a progressive enhancement, you can add this now. Note that this is different than some of the other features we were looking at where support is required for your site to work. Because your content is still available in order older browsers, just a bit unbalanced, this is fine to start using early. Uh another one is when you have long paragraphs of text. No one wants to have just one word hanging. um out by itself at the end of a paragraph. On the right, we're using the new text rap pretty. There will never be one lot or one word at the end. The normal text wrap rap, there will be times where it's just not pretty. And even without full support, you can add this, it'll just be ignored in browsers without it.

16:56

And you can make text shrink and grow to fit its container with text fit. So with grow, the longest line of text grows to the size of its container if it's smaller. And with shrink, the text shrinks to fill the container unless it has to wrap first. And this is currently just in Chromium browsers. And combining that with another new feature, textbox trim, which adjusts the space around your text, so it shows another solution to the CSS is awesome meme where if we change the size here. Awesome is just going to fit or shrink to fit no matter what, and CSS does as well. Um text box trim where you're changing the size of the I was trimming the area around the words. Um that should be coming soon. It's not in Firefox yet, but I saw progress um in the last week or two, so that would make that newly available.

17:48

So uh another one, I have a love -hate relationships with the select element. It's accessible, useful, and by default matches the UI of the user's device. But it's not beautiful and it doesn't match your site's UI. But with customizable selects, you can make much more designed experiences with just CSS and HTML with no uh no need to import a library. This is one possibility. Or you could even go crazy here. This is a new one that's uh from Tamani Afief. And you can't quite see it, but this is uh just HTML. There's um a select and option It's good semantic HTML. It'll work just with the default system UI on screen readers, mobile devices, the 10-year-old iPad you hand it down to your kid.

18:39

There's no JavaScript. All of the all of the presentation is in CSS. This is still very much in the early days, but there's active development and effort to make this and all the other form elements much more themeable. So lots of times you uh uh when you navigate between two pages, there are pieces of the views that are common between them The default on the web is you see the old view and then it instantly gets replaced with the new view. This can be jarring and users can lose context. View transitions help you smooth that out. The simplest use case is to have both pages opt in with a simple view transition at rule. So this activates a default uh fade through transition. And this is how it looks on the default

19:25

out-of-the-box Django admin site. These are two separate HTML documents, and yet there's a transition between them. And with a bit of JavaScript to determine direction and just a few keyframes, you can have transitions back and forth as you navigate through your site. And that can give your users a sense of depth, order, and flow, and can help keep them mentally oriented as they move through the app. And in the future, you might even be able to do that all in CSS without JavaScript. Another use case is where there's part of your page that exists before and after the tr the uh a navigation, um like a title uh or an image, and by giving both items a shared view transition name When a user navigates between the two pages, the browser automatically transitions between them. That includes the position

20:10

and even the color, and of course you can make that actually useful and look good. You can also use view transitions in single page applications or in other places where you're changing the state, but not the actual document. So like if you're just changing the theme on your site, you can add a view transition there as well. But this isn't relegated just to the files of quirky things to throw in a demo. This is something you can design to intentionally guide your users through the site and create continuity and improve their experience. View transitions for single-page applications are newly available. Um for cross-document view transitions, that should be coming yet this year. And the ability to transition just parts of the page without blocking um other parts is

20:59

A longstanding request on the internet has been to style an element based on its context or the state of its parents, and let's look at how that's useful. So you've likely used media queries to implement a responsive design or seen something like this. Uh in this case, the um we are wanting to say uh let's see, we uh If it's 100% by default it's um it's they're they're next to each other, but if it's smaller than 640 pixels, they stack. Um but this is based on the screen size, and this only works because we're styling it relative to the the whole viewport or the screen. So if you add a sidebar, then our calculations are off and the things get really small before they finally stack.

21:47

That's not what you intended. Wouldn't it be nice to change based on the width of a container rather than the width of the screen? But this was blocked by a conundrum. If you could set styles on a container, you could easily end up in a recursive loop. Luckily, they solved this by making it so you could only style children of the container that you are measuring. So this looks very simil uh similar, but we are declaring our main element as a container. And then using a container query instead of a media query. And we use a CQI unit, which is equal to 1% of the container's inline size, in this case the width. And now if we resize this. If I can grab that, you can see it resizes much earlier when when the main element

22:32

it changes, not when the viewport is at 640 pixels. And container queries and container query units can be used for responsive text sizing and make response complex layouts And reuse components much easier to uh reason about. I'd recommend playing around with this demo. There's a lot in there that's kind of cool to see. And those are widely supported. They're out there and ready to use. They've been in browsers since 2023. And you're able to react to a lot more than just the size of a container. With uh style container queries, you can add styles based on the value of a custom property on your container. container. People are finding this useful for styling components based on a context you define, for instance to differentiate a component that is in the featured section versus one that isn't.

23:18

And those are newly supported. You can also style based on scroll state, like if the container is sticky positioned and is stuck on the top, or if you want to scroll to top button, but only if the user has scrolled away from the top. And those support is a little bit further out. Another exciting new feature is the ability to drive an animation's progress from the user's scroll rather than by time. So if you follow the World Cup, you might have seen something like this. And there's a lot happening here, but let's break it down. We have keyframes that are collapsing the games down and making them go up. Um instead of animating those keyframes over time, we're animating that as um based on the scroll. In this particular case, we're just animating how how much uh space is available for each of those.

24:04

We're also animating a gradient um across the entire viewport uh around each of the elements. And you can do a lot of really interesting scrolly telling with this, as the term some people use for that. And all of that is without JavaScript and the browser's handling scroll watching and the animations all performantly. But that demo didn't just show uh show scroll animations. There's a lot more. We're using scroll snapping um to snap uh um each thing or the them to the side. except for the last one which uh goes full or uh is snaps to the center. Um all the container uh connection lines are drawn with anchor positioning Um so that you don't have to worry about where the lines should be f um you just say from here to here and it draws them and it keeps track of that as things move.

24:53

So the browser is really powerful. HTML and CSS have come so far in the last few years. And together these things make it possible for you to make lots of great and creative experiences, hopefully with less hassle and better performance. Remember that you can view all these slides and the demos at talks. jamsw. com and all the support slides have links to the web features explore, which has more resources to use. each one. Thanks to my brother for the pit bird pictures and feel free to ask me questions anywhere. Thanks.

Presenters

Conference

DjangoCon US

August 24 - 28, 2026

Chicago, Illinois, USA

Note: We understand that names change, people change, and bodies change. We respect each individual's journey and privacy. If you have any concerns about a video or need us to remove content, please don't hesitate to contact us. We will handle your request with care and promptly address any issues.

More videos by James

More videos from DjangoCon US