Open62

State of HTML 2025で出てきた要素を順に見ていく

dai_zabzabdai_zabzab

<datalist>

フォームコントロール内でユーザーが選択できるプリセットのリストを提供しつつ、カスタムオプションも許可する方法。

<input name="country" list="countries">
<datalist id="countries">
  <option>Afghanistan</option>
  ...
</datalist>

FireFox以外は気にせず使える要素。
コンボボックスみたいな感じで選択肢を用意できる。
いろんなinput要素のtype属性に対応している

https://developer.mozilla.org/ja/docs/Web/HTML/Reference/Elements/datalist

dai_zabzabdai_zabzab

Customizable Select

スタイル設定可能でカスタマイズ可能なドロップダウンコントロール。旧称<selectlist>および<selectmenu>。

select,
::picker(select) {
  appearance: base-select;
}

以前selectmenuなどで、OpenUIから提唱されていた要素はCustomizable Selectになった模様

https://qiita.com/degudegu2510/items/9754db3f6c60e69fffff
https://open-ui.org/prototypes/selectmenu/

OpenUIも更新されていた
https://open-ui.org/components/selectlist/

Selectlist has been renamed to customzable select. See the new explainer here.

リンク先がこちら
https://open-ui.org/components/customizableselect/

dai_zabzabdai_zabzab

<input type="color">

ユーザーが色値を選択できるカラーピッカーを作成します。

カラーピッカーを選択できるinput要素

dai_zabzabdai_zabzab

<input type="color" colorspace="display-p3">

広色域(P3)カラーを選択できるカラーピッカーを作成します。

カラーピッカーでdisplay-p3というものを扱えるらしい

https://developer.mozilla.org/en-US/docs/Glossary/Color_space#display-p3

display-p3 カラースペース
Appleによって定義されたDisplay P3カラースペースは、DCI-P3色域、D65白色点、sRGBガンマ曲線を組み合わせたものです。これは現在の広色域モニターに典型的な広色域空間であり、sRGB色域よりも鮮やかな緑と赤を表現できます。display-p3はr、g、bを基にしており、色域内の値は0から1の範囲です。白色点はD65です。

dai_zabzabdai_zabzab

<input type="color" alpha>

半透明の色を選択できるカラーピッカーを作成します。

カラーピッカーで半透明を扱えるらしい
ほとんどのブラウザで未対応

dai_zabzabdai_zabzab

contenteditable="plaintext-only"

要素の生テキストの編集は許可しますが、リッチテキストの書式設定は許可しません。

<h2 class="title" contenteditable="plaintext-only"></h2>
dai_zabzabdai_zabzab

<details> and <summary>

インタラクティブにコンテンツの表示/非表示を切り替えられる開示ウィジェット。

<details>
    <summary>Details</summary>
    Longer content
</details>

知らない人の方が少ないはず、、

<details name>

<details>要素をグループ化し、グループ内で同時に開くことができるのは最大1つだけとなるようにする。

<details open name="sidebar_panel">
	<summary>Main info</summary>
	<!-- controls -->
</details>
<details name="sidebar_panel">
	<summary>Style</summary>
	<!-- controls -->
</details>

JSの制御をせずに開閉する要素を一つにできる。
nameがないものがディスクロージャー、nameがあるものがアコーディオンと
区別できるのかもしれない

https://azukiazusa.dev/blog/details-name-attribute-accordion/

dai_zabzabdai_zabzab

Popover API

オーバーレイ、ポップアップ、メニューなどのポップオーバーを実現するHTML構文とJS API

popovertarget属性とpopover属性の組み合わせで、ポップオーバーを表現できる

dai_zabzabdai_zabzab

command and commandfor attributes (Command Invokers)

<button>が事前定義されたカスタムコマンドを呼び出す宣言的な方法。

現状、実験的な機能の様子
ダイアログのような元々あるイベントであれば、キーワードを使用することで制御可能
カスタムコマンドを使う場合にはJSでの登録が必要っぽい

https://developer.mozilla.org/ja/docs/Web/API/HTMLButtonElement/command

https://momdo.github.io/html/dev/form-elements.html#attr-button-command
https://momdo.github.io/html/dev/form-elements.html#attr-button-commandfor

dai_zabzabdai_zabzab

navigator.xr (WebXR Device API)

互換性のある出力デバイスでAR/VRセッションを作成する。

Web上でARやVRを使えるようにするもののようです。

https://developer.mozilla.org/ja/docs/Web/API/WebXR_Device_API

WebXRは、 WebXR 機器 API を中核として、拡張現実と仮想現実(AR および VR)の両方をウェブ上で実現するために必要な機能を提供します。これらの技術を合わせて、複合現実 (MR) またはクロス現実 (XR) と呼びます。

https://www.w3.org/TR/webxr/

dai_zabzabdai_zabzab

JPEG XL

ウェブ環境向けに最適化された画像フォーマット。

https://zenn.dev/sorairolake/articles/compress-jpeg-with-jxl

JPEG XLはJPEGやPNGなどの従来の形式よりも高い圧縮率を実現しており、非可逆圧縮と可逆圧縮、アニメーション、アルファチャンネル、HDR、広色域などのモダンな機能を提供していますが、これらは部分的も含めてAVIFやWebPでも対応しています。

https://jpeg.org/jpegxl/
https://ja.wikipedia.org/wiki/JPEG_XL

dai_zabzabdai_zabzab

Intl.Segmenter API

言語に依存したテキストのセグメンテーション(文字単位、単語単位、文単位への分割)

Intl自体は国際化のためのAPI

const segmenterFr = new Intl.Segmenter("fr", { granularity: "word" });
const string1 = "Que ma joie demeure";

const iterator1 = segmenterFr.segment(string1)[Symbol.iterator]();

console.log(iterator1.next().value.segment);
// Expected output: 'Que'

console.log(iterator1.next().value.segment);
// Expected output: ' '

https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter
https://zenn.dev/cybozu_frontend/articles/explore-intl-segmenter

dai_zabzabdai_zabzab

遅延読み込み

特定のリソースは必要な時のみ読み込む。

<img src="picture.jpg" loading="lazy" />
<iframe src="supplementary.html" loading="lazy"></iframe>
dai_zabzabdai_zabzab

srcset and sizes attributes

複数のソース画像を提供し、ブラウザが適切な画像を選択するのに役立つヒントを付与できる属性。

<img
  srcset="fairy-med.jpg 480w, fairy-large.jpg 800w"
  sizes="(max-width: 600px) 480px, 800px"
  src="fairy-large.jpg"
  alt="Elva dressed as a fairy" />

https://ics.media/entry/13324/

dai_zabzabdai_zabzab

blocking="render"

特定のリソースが読み込まれるまで、ブロックのレンダリング(ただし解析は除く)を遅延させる。<link>、<script>、<style> で利用可能。

<script blocking="render" async src="async-script.js"></script>
dai_zabzabdai_zabzab

<link rel="expect">

href値で参照される要素が接続され、完全に解析されるまでレンダリングをブロックする。

<link rel="expect" href="#hero" blocking="render">

https://developer.mozilla.org/ja/docs/Web/HTML/Reference/Attributes/rel#expect

文書の重要な部分が解釈できるまで、ページがレンダリングブロックされるようにします。これにより、ページは一貫性を保ってレンダリングされます。レンダリングブロックは、 blocking="render" 属性が追加されている場合にのみ発生することに注意してください。

https://webstatus.dev/features/link-rel-expect

dai_zabzabdai_zabzab

Speculation Rules

ブラウザがパフォーマンス向上のために、バックグラウンドでページを積極的にダウンロードするよう促すヒント。

<script type="speculationrules">
  {
    "prefetch": [{ "urls": ["/about", "/pricing"] }],
    "prerender": [
      {
        "where": {
          "href_matches": "^/product/\\d+$",
          "selector_matches": "a.nav-link"
        }
      }
    ]
  }
</script>

https://developer.mozilla.org/ja/docs/Web/HTML/Reference/Elements/script/type/speculationrules

dai_zabzabdai_zabzab

Declarative Custom Elements

HTMLを通じて宣言的にWebコンポーネントを作成します。JavaScriptの有無は問いません。

<definition name="progress-ring">
  <template shadowmode="open">
    <div id="base" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="{{root.attributes.percentage.value}}">
      <slot>{{ root.attributes.percentage.value }}%</slot>
    </div>
    <style>#base { /* ... */ }</style>
  </template>
</definition>

<progress-ring value="50"></progress-ring>

https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM
https://azukiazusa.dev/blog/declarative-shadow-dom/

dai_zabzabdai_zabzab

宣言的Shadow DOM

サーバーサイドレンダリングを行うWebコンポーネントなどにおいて、HTMLでシャドウツリーを定義する。

<host-element>
    <template shadowrootmode="open">
        <!-- Shadow content -->
    </template>
</host-element>
dai_zabzabdai_zabzab

命令的スロット割り当て

JSを介して要素を手動でスロットに割り当てる方法。これにより、コンポーネントの利用者がスロットの割り当てを管理する必要がなくなります。

this.attachShadow({mode: "open", slotAssignment: "manual" });
let headerSlot = this.shadowRoot.querySelector("slot[name=header]");
let header = this.querySelector("header");
if (header) headerSlot.assign(header);

https://developer.mozilla.org/ja/docs/Web/API/Element/attachShadow

dai_zabzabdai_zabzab

Reference Target API

コンポーネントのID参照を、そのシャドウDOM内の要素(ARIA、ラベル、ポップオーバーなど)へ「リダイレクト」する方法。

this.attachShadow({ 
  mode: "open",
  referenceTarget: "real-input",
});
this.shadowRoot.innerHTML = `<input id="real-input">`;
dai_zabzabdai_zabzab

PaymentRequest API

ウェブサイトがブラウザのネイティブUIを使用して支払いを要求するための一貫性のある安全な方法を実現します。

const request = new PaymentRequest(
  [{ supportedMethods: "basic-card" }], 
  { total: { label: "Total", amount: { currency: "USD", value: "9.99" } } }
);
let response = await request.show();
response.complete("success"));

https://developer.mozilla.org/ja/docs/Web/API/Payment_Request_API
https://qiita.com/taquaki-satwo/items/565eb60228240c80385a