WebDev Bites: Spacer Component Interface

horizontal and vertical spacer elements

0.75rem Components <v-s> and <h-s> are user-defined HTML elements that insert vertical and horizontal space where they are declared in the page flow. Their size measure can be supplied either as included content or with an attribute, as illustrated below. Their colors can be styled with inline or inherited declarations.

Spacer Components public Interfaces

0.25rem

Tags & Aliases

RoleTags
Horizontal spacer <h-space>...</h-space>  |  short alias: <h-s>...</h-s>
Vertical spacer <v-space>...</v-space>  |  short alias: <v-s>...</v-s>

Size Input Precedence

  1. Attribute: <h-s size="20rem"></h-s>
  2. Inner text: <h-s>20rem</h-s>
  3. CSS var on host: <h-s style="--h-space-size: var(--gap-xl)"></h-s>
  4. Default: 1rem

Note: Unitless values are treated as rem (e.g., 22rem).

Attributes

ComponentAttributes
Common
  • size: CSS length for the gap (e.g., 12px, 1.5rem, 6ch, var(--gap)).
<h-space> / <h-s>
  • block: if present, renders as display:block (default inline-block).
  • thickness: optional visual height to show spacer background/border; default 0 (examples: 2px, 0.25rem).
<v-space> / <v-s>
  • inline: if present, renders as display:inline-block (default block).

CSS Custom Properties (host)

NamePurpose
--h-space-size Width of <h-space>/<h-s>.
--h-thickness Height (visual thickness) of <h-space>/<h-s> (default 0).
--v-space-size Height of <v-space>/<v-s>.

Styling & Behavior

JS Properties

Examples

<span>abc</span><h-s>20rem</h-s><span>123</span>    
<h-s size="28rem" thickness="2px" style="background-color: orange;"></h-s>
<v-s>1.5rem</v-s>  Line 1 <v-s inline>0.75rem</v-s> Line 2
<h-s style="--h-thickness:2px; background-color: rgba(255,165,0,.5)">var(--gap-xl)</h-s>
10rem