Tip
Stop writing unnecessary, heavy, thread-blocking JavaScript — Una Kravets
Tip
CSS is now the most powerful design tool for the Web — Matthias Ott
Tip
With all the new web features right on their way (view-transitions, @starting-style, calc-size(), speculation rules, style and container queries, relative color syntax, ... the list goes on and on), it's time to face it... 🫣👇 — Stefan Judis
- The
<dialog>
element - The
<details>
element - The customizable
<select>
element - The
popover
attribute - The
command
attribute - The
focusgroup
attribute - The
switch
attribute - The
CloseWatcher
api
- Document element (1):
<html>
- Document metadata (6):
<head>
,<title>
,<base>
,<link>
,<meta>
,<style>
, - Sections (15):
<body>
,<article>
,<section>
,<nav>
,<aside>
,<h1-6>
,<hgroup>
,<header>
,<footer>
,<address>
- Grouping content (16):
<p>
,<hr>
,<pre>
,<blockquote>
,<ol>
,<ul>
,<menu>
,<li>
,<dl>
,<dt>
,<dd>
,<figure>
,<figcaption>
,<main>
,<search>
,<div>
- Text-level semantics (29):
<a>
,<em>
,<strong>
,<small>
,<s>
,<cite>
,<q>
,<dfn>
,<abbr>
,<ruby>
,<rt>
,<rp>
,<data>
,<time>
,<code>
,<var>
,<samp>
,<kbd>
,<sub>
,<sup>
,<i>
,<b>
,<u>
,<mark>
,<bdi>
,<bdo>
,<span>
,<br>
,<wbr>
- Edits (2):
<ins>
,<del>
- Embedded content (13):
<picture>
,<source>
,<img>
,<iframe>
,<embed>
,<object>
,<video>
,<audio>
,<track>
,<map>
,<area>
,<math>
,<svg>
- Tabular data (10):
<table>
,<caption>
,<colgroup>
,<col>
,<tbody>
,<thead>
,<tfoot>
,<tr>
,<td>
,<th>
- Forms (14):
<form>
,<label>
,<input>
,<button>
,<select>
,<datalist>
,<optgroup>
,<option>
,<textarea>
,<output>
,<progress>
,<meter>
,<fieldset>
,<legend>
- Interactive elements (3):
<details>
,<summary>
,<dialog>
- Custom elements (2):
<template>
,<slot>
- Scripting (3):
<script>
,<noscript>
,<canvas>
- Experimental (1):
<portal>
- Proposed (-):
<selectedoption>
Note
These last element landed in the HTML spec was the <search>
element, at March 24th 2023.
figure {
container-name: figure;
--featured: true;
}
@container figure style(--featured: true) {
figcaption {
/* Custom styling */
}
}
- Container Style Query Explainer by Miriam Suzanne
- CSS Style Queries Use Cases
- CSS Style Container Queries (custom properties) #828
- #10744 Allow applying style rules to the container itself
- CSS Values and Units Module Level 5
- #10064 [css-values-5] What is the MVP for inline conditionals on custom properties? 🔥
zx-tag {
/* if(condition(): foo; else: bar) */
background-color: if(
(--variant: success): green;
else: white;
);
}
- 2021-03-06 — First Proposal by Melanie Richards (Microsoft)
- 2023-03-15 — Future CSS: Anchor Positioning
- 2023-06-29 — First Working Draft
- 2023-12-14 — Anchor Positioning ⭐
- 2024-02-09 — Editor’s Draft
- 2024-04-12 — Chromium Intent to Ship: CSS Anchor Positioning
- Una's anchor-tool
- Una's bunch of demos
inset-area
demo exploration- csswg-drafts > css-anchor-position-1
- Chromium tracking bug
- Mozilla tracking bug
- Explainer: CSS Anchor Positioning
- #9663 Better handle an inset-area edge case
- Tracking bug for implementation of Anchor Positioning feature
- WebKit Position
- Mozilla Position
- Tether elements to each other with CSS anchor positioning by Jhey Tompkins (one of the spec editors)
.anchor {
anchor-name: --my-anchor;
}
.tooltip {
/* Fixpos means we don’t need to worry about
containing block relationships;
the tooltip can live anywhere in the DOM. */
position: fixed;
/* All the anchoring behavior will default to
referring to the --tooltip anchor. */
position-anchor: --tooltip;
/* Align the tooltip’s bottom to the top of the anchor;
this also defaults to horizontally center-aligning
the tooltip and the anchor (in horizontal writing modes). */
inset-area: block-start;
/* Automatically swap if this overflows the window
so the tooltip’s top aligns to the anchor’s bottom
instead. */
position-try: flip-block;
/* Prevent getting too wide */
max-inline-size: 20em;
}
Update April 2024: here is all the code you need to get a basic anchor now:
#my-tooltip {
/* Set the bottom of the anchored element (tooltip) to the top of the anchoring element */
bottom: calc(anchor(top));
/* If can't fit it in the screen anymore, flip the anchored element in the block direction */
position-try-options: flip-block;
/* Center the anchor with justification */
justify-self: anchor-center;
}
[popover] {
top: anchor(top);
left: anchor(right);
position-try-options: flip-block, flip-inline;
}
- CSS Scroll-triggered Animations with Style Queries
- Scroll-Driven Animations: You want overflow: clip, not overflow: hidden
- Demo: show off Scroll-driven Animations
- Demo: CSS-Only Sticky CTA
- Real World examples
@keyframes slide-left {
from { transform: scale(0.7); }
to { transform: scale(1); }
}
.scroll-animate-slide-left {
transform-origin: top right;
animation: slide-left ease-out both;
animation-timeline: view(block -64px);
animation-range: entry 0% entry 50%;
}
::highlight(example) {
color: hotpink;
}
Ability to animate discrete animations, such as animating to and from display: none
.
.card {
transition: opacity 0.25s, display 0.25s;
transition-behavior: allow-discrete; /* Note: be sure to write this after the shorthand */
}
.card.fade-out {
opacity: 0;
display: none;
}
- 2024-02-24 — View transitions: Handling aspect ratio changes
- 2024-11-17 — Bramus - Supercharge Web UX with View Transitions! - React Brussels 2024
- :any-link
- :empty
- :first-child
- :focus-visible
- :focus-within
- accent-color
- aspect-ratio
- backdrop-filter
- border-image
- caret-color
- columns
- drop-shadow()
- fit-content()
- gap
- inset
- list-style
- matrix3d()
- object-fit
- overscroll-behavior
- scroll-margin
- scroll-snap
- @supports (hover)
.container {
display: flex;
flex-direction: column;
align-items: safe center;
width: 38%;
}
.overlay {
border-image: fill 0 linear-gradient(#0003, #000);
}
- 12 Days of Web
- Interop 2024 Dashboard
- CSS Wrapped 2023
- New to the web platform
- Better, Faster, Stronger Web UI by Una Kravets
- Modern CSS patterns in Campfire
- Write better CSS with modern CSS
- The latest in Web UI (Google I/O ‘24)
- Adam Argyle blog
- Transition to
height: auto
&display: none
Using Pure CSS
<dialog>
: modal content, sidebars<details>
: accordions, disclosurespopover
: menus, custom toast notifications, content pickersanchor
: tooltips