# Block Markup Reference ## Comment Syntax WordPress blocks are serialized as HTML comments with JSON attributes. ```html
Inner content
(self-closing, no inner content) ``` Rules: - Opening tag: `` - Core blocks omit namespace: `` (not `core/heading`) - JSON must be valid — no trailing commas, strings double-quoted - Self-closing blocks (spacer, separator, image with no caption): end with `/-->` - Every opening comment **must** have a matching closing comment ## Most-Used Blocks in Patterns ### Layout Blocks **Group** — primary container, supports all layout types: ```html
``` Layout types: - `{"type":"constrained"}` — centered with max-width (default for sections) - `{"type":"constrained","contentSize":"800px","wideSize":"1200px"}` — custom widths - `{"type":"flex","flexWrap":"nowrap"}` — horizontal row - `{"type":"flex","orientation":"vertical"}` — vertical stack - `{"type":"grid","columnCount":3}` — CSS grid with fixed columns - `{"type":"grid","minimumColumnWidth":"250px"}` — responsive auto-fill grid Tag name override: `{"tagName":"section"}`, `{"tagName":"header"}`, `{"tagName":"footer"}` **Columns / Column:** ```html
``` ### Content Blocks **Heading:** ```html

Heading text

``` **Paragraph:** ```html

Body text

``` **Image:** ```html
Descriptive alt text
``` **Cover:** ```html
``` **Buttons / Button:** ```html
Click me
Secondary
``` **Spacer:** ```html ``` **Separator:** ```html
``` **Media & Text:** ```html
Description
``` **Query Loop (post listing):** ```html
``` ## Style Attribute Structure The `style` attribute holds custom values (not preset slugs): ```json { "style": { "spacing": { "padding": {"top":"var:preset|spacing|50","right":"var:preset|spacing|50","bottom":"var:preset|spacing|50","left":"var:preset|spacing|50"}, "margin": {"top":"0","bottom":"0"}, "blockGap": "var:preset|spacing|30" }, "border": { "radius": "8px", "width": "1px", "color": "var:preset|color|contrast", "style": "solid" }, "color": { "background": "#1a1a2e", "text": "#ffffff", "gradient": "linear-gradient(135deg,rgb(6,147,227) 0%,rgb(155,81,224) 100%)" }, "typography": { "fontSize": "clamp(1rem, 2vw, 1.5rem)", "lineHeight": "1.4", "letterSpacing": "-0.02em" } } } ``` Preset reference syntax in style values: `var:preset|{type}|{slug}` (not CSS `var()`) ## Preset Class Naming Convention When using preset slugs (not inline style), blocks get CSS classes: - `"backgroundColor":"primary"` → `has-primary-background-color has-background` - `"textColor":"contrast"` → `has-contrast-color has-text-color` - `"fontSize":"large"` → `has-large-font-size` - `"fontFamily":"heading"` → `has-heading-font-family` - `"gradient":"vivid-cyan-blue-to-vivid-purple"` → `has-vivid-cyan-blue-to-vivid-purple-gradient-background has-background` ## Block Locking Prevent users from modifying pattern structure: ```json { "lock": {"move": true, "remove": true} } ``` On container blocks, `templateLock` constrains children: - `"templateLock":"all"` — no insert, move, or remove - `"templateLock":"insert"` — no adding/removing, can move - `"templateLock":"contentOnly"` — only text/media editable, structure locked ## Block Alignment Use `align` attribute for wide/full-width: ```json {"align":"wide"} {"align":"full"} ```