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

style

Embeds a CSS stylesheet in the document. Covers cascade-layer placement against VB's layers, media-scoped blocks, CSP nonces, render blocking, and why a style block or tokens beat style attributes.

Description

The <style> element holds CSS for the document it sits in. It belongs in the <head>. Its rules join the cascade exactly like a linked stylesheet at the same position, so the usual tools apply: cascade layers, specificity and source order.

For anything reused across pages, prefer a linked stylesheet (<link rel="stylesheet">), which the browser can cache. A <style> block suits page-specific rules, demos and critical CSS.

Cascade Layers in VB

VB declares its layer order once, in main.css:

Later layers win over earlier ones. Themes self-declare @layer bundle-theme, so they sit above every framework layer. Unlayered CSS beats every layer, whatever its specificity. That is how your own <style> block overrides VB without !important.

  • Override VB: write plain, unlayered rules. They win.
  • Extend VB at a given level: wrap rules in one of VB's layer names, e.g. @layer native-elements { … }. They then compete normally with VB's own rules in that layer, and themes still apply on top.
  • Link main.css (which declares the order) before any <style> that names a VB layer. A layer first named in your block would otherwise be created in the wrong position.

See Overrides for the full layer contract.

Style Blocks, Tokens and the style Attribute

VB's conformance check (vb/no-inline-style) flags style="…" attributes, not <style> elements. Inline attributes cannot be layered, overridden by themes, scoped by media queries or reused. Move the rule into a <style> block or stylesheet, and use design tokens for the values.

For per-element values, use a data attribute that CSS reads, or one of the documented layout custom properties (--layout-min, --layout-threshold, --layout-content-min), which the conformance check allows.

Media-Scoped Blocks

The media attribute applies the whole block only when the query matches. It is equivalent to wrapping the contents in @media.

Security: CSP Nonces

A strict Content Security Policy blocks inline styles unless they carry the response's nonce, listed in style-src. Note that a nonce allows a <style> element but never a style="" attribute; that is one more reason to avoid style attributes.

Attributes

Attribute Description
media Media query; the block applies only when it matches. Defaults to all.
blocking="render" Explicitly hold rendering until the styles are ready. A <style> in the <head> is already render-blocking; the attribute matters mostly for blocks inserted by script.
nonce One-time token matching the CSP style-src directive.
title Puts the block in a named style sheet set. Blocks whose title differs from the first titled sheet become alternates and are disabled, so leave it off.

The element also accepts the global attributes. The old type="text/css" attribute is unnecessary.

Accessibility

  • Never hide content that matters with CSS alone if assistive technology still reads it, or the reverse. Use hidden or VB's .visually-hidden deliberately.
  • Keep user preferences working: honour prefers-reduced-motion and VB's data-motion-reduced switch, and do not override focus outlines without a visible replacement.
  • Use colour tokens rather than hardcoded colours, so text keeps its contrast across themes and in dark mode.
  • CSS content text is announced inconsistently. Do not put essential information in generated content.

Related

  • <link> - External, cacheable stylesheets
  • Overrides - VB's cascade layers and how to override them
  • blocking - Render-blocking styles and scripts
  • nonce - CSP nonces
  • <script> - The scripting counterpart
↑