They come from the Future (frontend stuff)

Drupal Dev Days Vienna | July 2023
Nicolai Schwarz | textformer.de | @textformer

This presentation needed to work on my laptop. It is not completely optimized for mobile, but you will see all the important parts. Also not all examples will work in your browser. Best viewed in Chrome.

Anyway, you will probably only need the linklist right at the start.

They come from the future

Best viewed in Chrome. Not all examples
will work in other browsers.

Use arrow keys to switch slides.
Or swipe left/right on touch screens.

Nicolai Schwarz

Nicolai Schwarz
@textformer, textformer.de
Designer & Webdeveloper
Dortmund, Germany

mostly Frontend stuff
with Drupal & Backdrop CMS

written various articles in the last 15 years for Screenguide, PC Magazin, Webstandards Magazin, t3n, PHP Magazin

Icon Rocket
Icon Fast
Icon Link

Security

Content Security Policy

Use it: Right now!

The Content-Security-Policy helps you reduce XSS risks on modern browsers by declaring which dynamic resources are allowed to load.

You can e.g. declare sources for images, styles, scripts, fonts, frames …

CSP is implemented via HTTP response header or alternatively with a meta element.

Why is this useful?

  1. Prevent modules from loading stuff you don’t know about.
  2. Prevent editors from adding JavaScripts to Google Tag Manager.
  3. Prevents editors from hotlinking images.
Screenshot caniuse.com, see Link
caniuse.com/contentsecuritypolicy
Screenshot Drupal Project CSP
drupal.org/project/csp
Screenshot Drupal Project Security Kit
drupal.org/project/seckit

Performance

WebP

Use it: Right now!

WebP is an image format that supports lossy and lossless compression, animation and alpha transparency. It generally has better compression than JPEG, PNG and GIF and is designed to supersede them.

AVIF and JPEG XL are designed to supersede WebP.

Screenshot caniuse.com, see Link
caniuse.com/webp
Drupal image style, convert to WebP
If the server supports the format
Screenshot caniuse.com, see Link
caniuse.com/avif
Screenshot caniuse.com, see Link
caniuse.com/jpegxl

DesignAccessibility

:focus-visible

Use it: Right now! (last browser Safari added it in Mar 2022)

This selector is useful to provide a different focus indicator based on the user’s input modality: mouse vs. keyboard.

Screenshot of a slider component on jmberlin.de

:hover
:focus

:hover
:focus-visible

Screenshot caniuse.com, see Link
caniuse.com/css-focus-visible

CSS

Cascade Layers

Use it: Right now! (all big 5 browsers added this in spring 2022)

Screenshot caniuse.com, see Link
caniuse.com/css-cascade-layers

CSS

Individual transform properties

Use it: right now (Chromium browsers were last and added it in Aug 2022)

Now you may change translate, rotate & scale individually.

Screenshot caniuse.com, see Link
caniuse.com/mdn-css_properties_rotate

CSS

Container Queries

Use it: Right now! (last browser Firefox added it in Feb 2023)

Screenshot caniuse.com, see Link
caniuse.com/css-container-queries

CSS

Container Style Queries

Use it: Somewhere down the road …

Screenshot caniuse.com, see Link
caniuse.com/css-container-queries-style

Media Queries

Range Syntax

Use it: Right now (last browser Safari added it in Mar 23)

Syntax improvements to make media queries using features that have a »range« type (like width or height) less verbose – by using known mathematical comparison operators: >, <, >=, or <=.

Screenshot caniuse.com, see Link
caniuse.com/css-media-range-syntax

Mobile

New viewport units

Use it: Right now! (Chromium bowsers were last and added it in Nov/Dec 2022)

Illustrations of mobile phones showing large and small viewport units
12daysofweb.dev/2022/new-viewport-units/
Screenshot caniuse.com, see Link
caniuse.com/viewport-unit-variants

UsabilityAccesibility

inert

Use it: Right now, but carefully (last browser Firefox added it in Apr 2023)

The inert attribute is a Boolean attribute indicating that the browser will ignore the element.

Screenshot of jmberlin.de, showing the home page
Screenshot of jmberlin.de, showing the home page with an active navigation element in the front, the background is behind a dark layer

»Note: While inert is a global attribute and can be applied to any element, it is generally used for sections of content. To make individual controls "inert", consider using the disabled attribute, along with CSS :disabled styles, instead.«
› see developer.mozilla.org

Screenshot caniuse.com, see Link
caniuse.com/mdn-html_global_attributes_inert

Color

Color Spaces & Functions

Use it: Right now!

The lab() and lch() color functions represent colors in a way that closely matches human perception and provides access to a wider spectrum of colors than offered by the usual RGB color space.

lab: lightness / a: how much green/red / b: how much blue/yellow

lch: lightness / chroma ("amount of color") / hue

»In LCH, the same numerical change in coordinates produces the same perceptual color difference. This property of a color space is called ›perceptual uniformity‹. RGB or HSL are not perceptually uniform.«

› see Lea Verou: LCH colors in CSS: what, why, and how?

hsl(30, 100%, 50%)
hsl(30, 100%, 50%)
hsl(50, 100%, 50%)
hsl(50, 100%, 50%)
hsl(230, 100%, 50%)
hsl(230, 100%, 50%)
hsl(250, 100%, 50%)
hsl(250, 100%, 50%)

Example from LCH colors in CSS: what, why, and how?

lch(60% 90 30)
lch(60% 90 30)
lch(60% 90 50)
lch(60% 90 50)
lch(60% 90 130)
lch(60% 90 130)
lch(60% 90 150)
lch(60% 90 150)
lch(60% 90 230)
lch(60% 90 230)
lch(60% 90 250)
lch(60% 90 250)

The changes in Hue are closer together.

Screenshot caniuse.com, see Link
caniuse.com/css-lch-lab

»Today, the gamut (range of possible colors displayed) of most monitors is closer to P3, which has a 50% larger volume than sRGB.«

› see Lea Verou: LCH colors in CSS: what, why, and how?

graph: comparison of different color spaces
The CIE 1931 chromaticity diagram showing the P3 gamut, and the gamuts of some other common RGB color spaces. – en.wikipedia.org/wiki/DCI-P3

oklab() and oklch() offer some additional improvements to lab() and lch().

› see Andrey Sitnik & Travis Turner: OKLCH in CSS: why we moved from RGB and HSL

»In short, OKLCH and LCH are both better choices for developer readability and color modification because the chroma and hue values are closer to how people actually think about color, rather than simply a and b.«

› see Andrey Sitnik & Travis Turner: OKLCH in CSS: why we moved from RGB and HSL

Screenshot caniuse.com, see Link
caniuse.com/mdn-css_types_color_oklab

There’s also a new color() functional notation that allows you to specify colors in predefined color spaces. Of course, the device screen and OS also need to support the color space being used.

Screenshot caniuse.com, see Link
caniuse.com/css-color-function

»The syntax for the rgb() and hsl() functions has changed with the intention of making them easier to use. The commas separating the values are no longer required and you can use a slash to specify an alpha value for the color.«

› see Brian Smith: New functions, gradients, and hues in CSS colors (Level 4)

Screenshot caniuse.com, see Link
caniuse.com/mdn-css_types_color_rgba_space_separated_parameters

The color-mix() functional notation takes two <color> values and returns the result of mixing them in a given colorspace by a given amount.

Screenshot caniuse.com, see Link
caniuse.com/mdn-css_types_color_color-mix

Color

Relative colors

Use it: Will take a while

With CSS Relative Color you can define a color relative to another color, using the from keyword and optionally calc() for any of the color values.

Screenshot caniuse.com, see Link
caniuse.com/css-relative-colors

SecurityUsabilityAccessibility

Web Authentication API

Use it: Soon-ish?

The Web Authentication API allows servers to register and authenticate users using public key cryptography instead of a password. E.g. log in with your phone and your fingerprint.

Screenshot caniuse.com, see Link
caniuse.com/webauthn

Typography

text-wrap: balance

Use it: Right now (as it doesn’t break anything)

text-wrap: balance allows multiple lines of text to have their lines broken in such a way that each line is roughly the same width, often used to make headlines more readable and visually appealing.

without text-wrap: balance

Hollywood grinds to a halt on first full day of joint actors’ and writers’ strikes

with text-wrap: balance

Hollywood grinds to a halt on first full day of joint actors’ and writers’ strikes

Screenshot caniuse.com, see Link
caniuse.com/css-text-wrap-balance

Typography

text-wrap: pretty

Use it: Not yet (might land in Chrome 117)

»The balance value is more about balancing the text in a way that the last line of an element is as long as the first line. The pretty value almost behaves the same way but it’s more about preventing the single word on the last line when there are multiple lines in the element.«

› see Amit Merchant: Text Wrap Pretty is coming to CSS

CSS

CSS Nesting

Use it: Very soon (waiting for next Firefox version)

Screenshot caniuse.com, see Link
caniuse.com/css-nesting

CSS

:has (parent selector)

Use it: As soon as Firefox has it (or with Polyfill)

two teaser elements, one has just text, the other has an image and text
Screenshot caniuse.com, see Link
caniuse.com/css-has

AnimationUsability

View Transitions API

Use it: Currently in Chrome, Edge & Opera (SPA)

»The View Transition API makes it easy to change the DOM in a single step, while creating an animated transition between the two states.«

› see developer.chrome.com: Smooth and simple transitions with the View Transitions API

Default crossfade, Chrome Demo
Entering and exiting sidebar, Chrome Demo
Multiple moving parts, Chrome Demo

»Although the current implementation targets single page apps (SPAs), this feature will be expanded to allow for transitions between full page loads, which is currently impossible.«

› see developer.chrome.com: Smooth and simple transitions with the View Transitions API

Screenshot caniuse.com, see Link
caniuse.com/mdn-api_document_startviewtransition

LayoutAccessibility

popover Attribut / API

Use it: Currently in Chrome, Edge; soon in Safari

The Popover API provides developers with a standard, consistent, flexible mechanism for displaying popover content on top of other page content.
Popover content can be controlled either declaratively using HTML attributes, or via JavaScript.

I am a popover with more information.

Screenshot caniuse.com, see Link
caniuse.com/mdn-html_global_attributes_popover

popover vs. <dialog>

»With a modal dialog, the rest of the page (outside the dialog) is rendered inert, so that only the contents of the dialog are interactable.
Importantly, a popover is non-modal. Almost by definition, a popover is not permanent: it goes away (via light dismiss) when the user changes their attention to something else, by clicking or tabbing to something else.«

› see open-ui.org: Popover API (Explainer)

Animations

Scroll-Linked Animations

Use it: Not yet (can be enabled in Chrome, Edge, Opera)

Reading Indicator, Chrome Demo
Cover Flow, Chrome Demo
Screenshot caniuse.com, see Link
caniuse.com/css-scroll-timeline

Typography

Initial Letters

Use it: Partial support in Chrome, Edge, Opera & Safari

Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.

Screenshot caniuse.com, see Link
caniuse.com/css-initial-letter

HTMLAccessibility

<search> element

Use it: Will take some time

ARIA roleHTML element
Bannerheader
Complementaryaside
contentinfofooter
formform
mainmain
navigationnav
regionsection
search-
Screenshot caniuse.com, see Link
caniuse.com/mdn-html_elements_search

CSS

@when / @else

Was an unofficial Proposal Draft by Tab Atkins-Bittner, September 2018

Made it into CSS Conditional Rules Module Level 5,
W3C First Public Working Draft, December 2021

CSS When/Else Rules is a proposal to extend the concept of CSS conditional rules to arbitrary @when-@else-chains, and supporting this, a proposal to unify the disparate conditional rules into a single grammar.

Why don’t they use the more common @if?

To avoid conflicts with the preprocessor Sass – as Sass already uses @if, to control whether or not a style block gets evaluated.

Screenshot caniuse.com, see Link
caniuse.com/css-when-else

CSS

Anchor Positioning

First Public Working Draft, 29 June 2023

This specification defines anchor positioning, where a positioned element can size and position itself relative to one or more "anchor elements" elsewhere on the page.

For example, an author might want to position a tooltip centered and above the targeted element, unless that would place the tooltip offscreen, in which case it should be below the targeted element.
See the draft.

Accessibilty

WAI-Adapt

Use it: years in the future

»People have very different needs. There are many people with cognitive and learning disabilities that affect their ability to interact with the web. […]
The various WAI-Adapt module specifications enable authors to selectively add semantic information about content to enable content and interface personalization for individual users.«
› see w3.org: WAI-Adapt Explainer

example for WAI Adapt: a simple web page
w3.org/TR/adapt/#proof-of-concept-symbol-example
example for WAI Adapt: a simple web page with added symbols
w3.org/TR/adapt/#proof-of-concept-symbol-example
example for WAI Adapt: a simple web page with added symbols
w3.org/TR/adapt/#proof-of-concept-symbol-example

CSS

CSS Toggle

Currently an unofficial Proposal Draft
by Tab Atkins and Miriam Suzanne

Toggle states with CSS instead of JavaScript.

E.g. for color schemes, tabs, accordions, carousels, off-canvas menus

› see: CSS Toggles Explainer & Proposal

› see: Demo Page (with Polyfill)

That’s all folks
Icon Link
textformer.de/ddd23