Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

bdi

Isolates text that might be formatted in a different direction from surrounding text.

Description

The <bdi> (Bidirectional Isolate) element tells the browser's bidirectional algorithm to treat the text it contains in isolation from its surrounding text. This is essential when embedding user-generated content or any text whose direction is unknown.

Without <bdi>, a username in Arabic or Hebrew can pull the punctuation and numbers that follow it into its right-to-left run, so they display in the wrong place. For example, محمد: 12 points renders as “12 :محمد points”.

When to Use

  • User-generated names: Usernames, display names, search queries from any locale
  • Database values: Any text retrieved from a data source whose direction you don't control
  • API responses: Text from external services
  • Leaderboards and lists: Mixed-script rankings
  • Chat messages: User-submitted messages in multilingual applications

When NOT to Use

  • For text whose direction you know — set it explicitly with dir="rtl" or dir="ltr" on the element (for example <bdi dir="rtl"> or <span dir="rtl" lang="ar">, which the browser also isolates). <bdo> is different: it forces character order and is rarely what you want.
  • For entire sections in a different language — use dir="rtl" or dir="ltr" on the container

Examples

Why Use bdi?

The problem appears when right-to-left text is directly followed by neutral characters (punctuation, spaces) and a number. The bidirectional algorithm treats them as part of the right-to-left run. Without <bdi>, the number jumps in front of the name:

When the RTL text sits between two left-to-right words (User محمد posted 3 comments.), it displays correctly either way. Wrapping dynamic values in <bdi> regardless is the safe default, because you can't know in advance what will follow them.

Dynamic Content

Always wrap user-generated content in <bdi> when the text direction is unknown:

bdi vs bdo

Element Purpose Direction
<bdi> Isolate — let the browser detect direction Defaults to auto
<bdo> Override — force a specific direction Requires dir="rtl" or dir="ltr"

Attributes

Supports global attributes. The dir attribute defaults to auto on <bdi> elements, meaning the direction is determined by the element's content.

CSS

VB adds no styling and no unicode-bidi rules for <bdi> or [dir] elements; the browser defaults apply. The element's value is purely in its Unicode isolation behavior.

Accessibility

<bdi> has no special accessibility role. It affects visual rendering only. Screen readers read the content in logical (source) order regardless of visual direction. Add lang when you know the language of the isolated text, so screen readers can pronounce it correctly.

Related

  • <bdo> — Forces a specific text direction (override)
  • <q> — Inline quotations with locale-aware quote marks
  • Internationalization guide — Full i18n reference including logical properties, ruby, and locale quotes
  • dir — Set or detect text direction
↑